Package net.bytebuddy.dynamic
Interface DynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
- Type Parameters:
U
- A loaded type that the built type is guaranteed to be a subclass of.
- All Known Subinterfaces:
DynamicType.Builder.MethodDefinition.ExceptionDefinition<U>
,DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<V>
,DynamicType.Builder.MethodDefinition.ParameterDefinition<U>
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Annotatable<V>
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<V>
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Simple<V>
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Simple.Annotatable<V>
,DynamicType.Builder.MethodDefinition.TypeVariableDefinition<U>
,DynamicType.Builder.MethodDefinition.TypeVariableDefinition.Annotatable<V>
- All Known Implementing Classes:
DynamicType.Builder.AbstractBase.Adapter.MethodDefinitionAdapter
,DynamicType.Builder.AbstractBase.Adapter.MethodDefinitionAdapter.ParameterAnnotationAdapter
,DynamicType.Builder.AbstractBase.Adapter.MethodDefinitionAdapter.SimpleParameterAnnotationAdapter
,DynamicType.Builder.AbstractBase.Adapter.MethodDefinitionAdapter.TypeVariableAnnotationAdapter
,DynamicType.Builder.AbstractBase.Adapter.MethodMatchAdapter
,DynamicType.Builder.AbstractBase.Adapter.OptionalMethodMatchAdapter
,DynamicType.Builder.MethodDefinition.ExceptionDefinition.AbstractBase
,DynamicType.Builder.MethodDefinition.ImplementationDefinition.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Annotatable.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Annotatable.AbstractBase.Adapter
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Simple.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Simple.Annotatable.AbstractBase
,DynamicType.Builder.MethodDefinition.ParameterDefinition.Simple.Annotatable.AbstractBase.Adapter
,DynamicType.Builder.MethodDefinition.TypeVariableDefinition.AbstractBase
,DynamicType.Builder.MethodDefinition.TypeVariableDefinition.Annotatable.AbstractBase
,DynamicType.Builder.MethodDefinition.TypeVariableDefinition.Annotatable.AbstractBase.Adapter
- Enclosing interface:
- DynamicType.Builder.MethodDefinition<S>
public static interface DynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
A builder for defining an implementation of a method.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
An abstract base implementation for a builder optionally defining an implementation of a method.static interface
A builder for optionally defining an implementation of a method. -
Method Summary
Modifier and TypeMethodDescriptiondefaultValue
(AnnotationValue<?, ?> annotationValue) Defines the previously defined or matched method to return the supplied value as an annotation default value.defaultValue
(W value, Class<? extends W> type) Defines the previously defined or matched method to return the supplied value as an annotation default value.intercept
(Implementation implementation) Implements the previously defined or matched method by the supplied implementation.Defines the previously defined or matched method not to declare a method body.
-
Method Details
-
intercept
DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<U> intercept(Implementation implementation) Implements the previously defined or matched method by the supplied implementation. A method interception is typically implemented in one of the following ways:- If a method is declared by the instrumented type and the type builder creates a subclass or redefinition, any preexisting method is replaced by the given implementation. Any previously defined implementation is lost.
- If a method is declared by the instrumented type and the type builder creates a rebased version of the instrumented type, the original method is preserved within a private, synthetic method within the instrumented type. The original method therefore remains invokeable and is treated as the direct super method of the new method. When rebasing a type, it therefore becomes possible to invoke a non-virtual method's super method when a preexisting method body is replaced.
- If a virtual method is inherited from a super type, it is overridden. The overridden method is available for super method invocation.
- Parameters:
implementation
- The implementation for implementing the previously defined or matched method.- Returns:
- A new builder where the previously defined or matched method is implemented by the supplied implementation.
-
withoutCode
DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<U> withoutCode()Defines the previously defined or matched method not to declare a method body. This implies the method to beabstract
unless it was already declared to benative
.- Returns:
- A new builder where the previously defined or matched method is implemented to be abstract.
-
defaultValue
DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<U> defaultValue(AnnotationValue<?, ?> annotationValue) Defines the previously defined or matched method to return the supplied value as an annotation default value. The value must be supplied in its unloaded state, i.e. enumerations asEnumerationDescription
, types asTypeDescription
and annotations asAnnotationDescription
. For supplying loaded types, usedefaultValue(Object, Class)
must be used.- Parameters:
annotationValue
- The value to be defined as a default value.- Returns:
- A builder where the previously defined or matched method is implemented to return an annotation default value.
-
defaultValue
<W> DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<U> defaultValue(W value, Class<? extends W> type) Defines the previously defined or matched method to return the supplied value as an annotation default value. The value must be supplied in its loaded state paired with the property type of the value.- Type Parameters:
W
- The type of the annotation property.- Parameters:
value
- The value to be defined as a default value.type
- The type of the annotation property.- Returns:
- A builder where the previously defined or matched method is implemented to return an annotation default value.
-