Package net.bytebuddy.dynamic
Class DynamicType.Builder.AbstractBase.Adapter.OptionalMethodMatchAdapter
java.lang.Object
net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase<U>
net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase.Delegator<U>
net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase.Adapter.OptionalMethodMatchAdapter
- All Implemented Interfaces:
DynamicType.Builder<U>
,DynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
,DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<U>
- Enclosing class:
DynamicType.Builder.AbstractBase.Adapter<U>
@Enhance(includeSyntheticFields=true)
protected class DynamicType.Builder.AbstractBase.Adapter.OptionalMethodMatchAdapter
extends DynamicType.Builder.AbstractBase.Delegator<U>
implements DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<U>
An adapter for optionally matching methods defined by declared interfaces.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase
DynamicType.Builder.AbstractBase.Adapter<U>, DynamicType.Builder.AbstractBase.Delegator<U>, DynamicType.Builder.AbstractBase.UsingTypeWriter<U>
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.DynamicType.Builder
DynamicType.Builder.AbstractBase<S>, DynamicType.Builder.FieldDefinition<S>, DynamicType.Builder.InnerTypeDefinition<S>, DynamicType.Builder.MethodDefinition<S>, DynamicType.Builder.RecordComponentDefinition<S>, DynamicType.Builder.TypeVariableDefinition<S>
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.DynamicType.Builder.MethodDefinition.ImplementationDefinition
DynamicType.Builder.MethodDefinition.ImplementationDefinition.AbstractBase<V>, DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TypeList.Generic
The interfaces whose methods are optionally matched. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
OptionalMethodMatchAdapter
(TypeList.Generic interfaces) Creates a new optional method match adapter. -
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
(V value, Class<? extends V> 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.Returns a matcher for the interfaces' methods.protected DynamicType.Builder
<U> Creates a new builder that realizes the current state of the builder.Defines the previously defined or matched method not to declare a method body.Methods inherited from class net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase.Delegator
annotateType, attribute, declaredTypes, define, defineConstructor, defineField, defineMethod, defineRecordComponent, field, ignoreAlso, ignoreAlso, implement, initializer, initializer, innerTypeOf, innerTypeOf, invokable, make, make, make, make, merge, modifiers, name, nestHost, nestMembers, permittedSubclass, recordComponent, recordComponent, require, suffix, topLevelType, toTypeDescription, transform, typeVariable, unsealed, visit, wrap, wrap
Methods inherited from class net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase
annotateType, annotateType, annotateType, constructor, declaredTypes, declaredTypes, declaredTypes, define, define, define, define, define, defineConstructor, defineConstructor, defineField, defineField, defineField, defineField, defineField, defineMethod, defineMethod, defineMethod, defineMethod, defineMethod, defineProperty, defineProperty, defineProperty, defineProperty, defineRecordComponent, field, implement, implement, implement, innerTypeOf, innerTypeOf, innerTypeOf, invokable, merge, method, modifiers, modifiers, nestHost, nestMembers, nestMembers, nestMembers, noNestMate, permittedSubclass, permittedSubclass, permittedSubclass, require, require, require, serialVersionUid, typeVariable, typeVariable, typeVariable, typeVariable, withHashCodeEquals, withToString, wrap, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.bytebuddy.dynamic.DynamicType.Builder
annotateType, annotateType, annotateType, annotateType, attribute, constructor, declaredTypes, declaredTypes, declaredTypes, declaredTypes, define, define, define, define, define, define, defineConstructor, defineConstructor, defineConstructor, defineField, defineField, defineField, defineField, defineField, defineField, defineMethod, defineMethod, defineMethod, defineMethod, defineMethod, defineMethod, defineProperty, defineProperty, defineProperty, defineProperty, defineRecordComponent, defineRecordComponent, field, field, ignoreAlso, ignoreAlso, implement, implement, implement, implement, initializer, initializer, innerTypeOf, innerTypeOf, innerTypeOf, innerTypeOf, innerTypeOf, invokable, invokable, make, make, make, make, merge, merge, method, modifiers, modifiers, modifiers, name, nestHost, nestHost, nestMembers, nestMembers, nestMembers, nestMembers, noNestMate, permittedSubclass, permittedSubclass, permittedSubclass, permittedSubclass, recordComponent, recordComponent, require, require, require, require, serialVersionUid, suffix, topLevelType, toTypeDescription, transform, typeVariable, typeVariable, typeVariable, typeVariable, typeVariable, unsealed, visit, withHashCodeEquals, withToString, wrap, wrap, wrap, wrap
-
Field Details
-
interfaces
The interfaces whose methods are optionally matched.
-
-
Constructor Details
-
OptionalMethodMatchAdapter
Creates a new optional method match adapter.- Parameters:
interfaces
- The interfaces whose methods are optionally matched.
-
-
Method Details
-
materialize
Description copied from class:DynamicType.Builder.AbstractBase.Delegator
Creates a new builder that realizes the current state of the builder.- Specified by:
materialize
in classDynamicType.Builder.AbstractBase.Delegator<U>
- Returns:
- A new builder that realizes the current state of the builder.
-
intercept
public 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.
- Specified by:
intercept
in interfaceDynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
- 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
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
.- Specified by:
withoutCode
in interfaceDynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
- Returns:
- A new builder where the previously defined or matched method is implemented to be abstract.
-
defaultValue
public 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, useDynamicType.Builder.MethodDefinition.ImplementationDefinition.defaultValue(Object, Class)
must be used.- Specified by:
defaultValue
in interfaceDynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
- 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
public <V> DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<U> defaultValue(V value, Class<? extends V> 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.- Specified by:
defaultValue
in interfaceDynamicType.Builder.MethodDefinition.ImplementationDefinition<U>
- Type Parameters:
V
- 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.
-
interfaceType
Returns a matcher for the interfaces' methods.- Returns:
- A matcher for the interfaces' methods.
-