S
- The most specific known loaded type that is implemented by the created dynamic type, usually the
type itself, an interface or the direct super class.public abstract static class DynamicType.Builder.AbstractBase<S> extends Object implements DynamicType.Builder<S>
TargetType
class can be used as a placeholder.Modifier and Type | Class and Description |
---|---|
protected class |
DynamicType.Builder.AbstractBase.AbstractDelegatingBuilder<U>
A base implementation of a builder that is capable of manifesting a change that was not yet applied to
the builder.
|
protected class |
DynamicType.Builder.AbstractBase.DefaultExceptionDeclarableMethodInterception
A
DynamicType.Builder.ExceptionDeclarableMethodInterception which allows the
definition of exceptions for a recently defined method. |
protected class |
DynamicType.Builder.AbstractBase.DefaultFieldValueTarget
A
DynamicType.Builder for which a field was recently defined such that attributes
can be added to this recently defined field. |
protected class |
DynamicType.Builder.AbstractBase.DefaultMatchedMethodInterception
A
DynamicType.Builder.MatchedMethodInterception for which a method was recently
identified or defined such that an Implementation for these methods can
now be defined. |
protected class |
DynamicType.Builder.AbstractBase.DefaultMethodAnnotationTarget
A
DynamicType.Builder.MethodAnnotationTarget which allows the definition of
annotations for a recently identified method. |
protected class |
DynamicType.Builder.AbstractBase.DefaultOptionalMatchedMethodInterception
Allows for the direct implementation of an interface after its implementation was specified.
|
protected static class |
DynamicType.Builder.AbstractBase.FieldToken
A field token representing a latent field that is defined for the built dynamic type.
|
protected static class |
DynamicType.Builder.AbstractBase.MethodToken
A method token representing a latent method that is defined for the built dynamic type.
|
DynamicType.Builder.AbstractBase<S>, DynamicType.Builder.ExceptionDeclarableMethodInterception<S>, DynamicType.Builder.FieldAnnotationTarget<S>, DynamicType.Builder.FieldValueTarget<S>, DynamicType.Builder.MatchedMethodInterception<S>, DynamicType.Builder.MethodAnnotationTarget<S>, DynamicType.Builder.OptionalMatchedMethodInterception<S>
Modifier and Type | Field and Description |
---|---|
protected TypeAttributeAppender |
attributeAppender
The type attribute appender specified for this builder.
|
protected AuxiliaryType.NamingStrategy |
auxiliaryTypeNamingStrategy
The naming strategy for auxiliary types specified for this builder.
|
protected BridgeMethodResolver.Factory |
bridgeMethodResolverFactory
The bridge method resolver factory specified for this builder.
|
protected ClassFileVersion |
classFileVersion
The class file version specified for this builder.
|
protected ClassVisitorWrapper.Chain |
classVisitorWrapperChain
The class visitor wrapper chain that is applied on created types by this builder.
|
protected FieldAttributeAppender.Factory |
defaultFieldAttributeAppenderFactory
The default field attribute appender factory that is automatically added to any field that is
registered on this builder.
|
protected MethodAttributeAppender.Factory |
defaultMethodAttributeAppenderFactory
The default method attribute appender factory that is automatically added to any field method is
registered on this builder.
|
protected FieldRegistry |
fieldRegistry
The field registry of this builder.
|
protected List<DynamicType.Builder.AbstractBase.FieldToken> |
fieldTokens
This builder's currently registered field tokens.
|
protected ElementMatcher<? super MethodDescription> |
ignoredMethods
The method matcher for ignored method specified for this builder.
|
protected List<TypeDescription> |
interfaceTypes
The interface types to implement as specified for this builder.
|
protected MethodLookupEngine.Factory |
methodLookupEngineFactory
The method lookup engine factory to be used by this builder.
|
protected MethodRegistry |
methodRegistry
The method registry of this builder.
|
protected List<DynamicType.Builder.AbstractBase.MethodToken> |
methodTokens
This builder's currently registered method tokens.
|
protected int |
modifiers
The modifiers specified for this builder.
|
protected NamingStrategy |
namingStrategy
The naming strategy specified for this builder.
|
protected TypeDescription |
targetType
The target type description that is specified for this builder.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractBase(ClassFileVersion classFileVersion,
NamingStrategy namingStrategy,
AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
TypeDescription targetType,
List<TypeDescription> interfaceTypes,
int modifiers,
TypeAttributeAppender attributeAppender,
ElementMatcher<? super MethodDescription> ignoredMethods,
BridgeMethodResolver.Factory bridgeMethodResolverFactory,
ClassVisitorWrapper.Chain classVisitorWrapperChain,
FieldRegistry fieldRegistry,
MethodRegistry methodRegistry,
MethodLookupEngine.Factory methodLookupEngineFactory,
FieldAttributeAppender.Factory defaultFieldAttributeAppenderFactory,
MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory,
List<DynamicType.Builder.AbstractBase.FieldToken> fieldTokens,
List<DynamicType.Builder.AbstractBase.MethodToken> methodTokens)
Creates a new immutable type builder base implementation.
|
Modifier and Type | Method and Description |
---|---|
DynamicType.Builder<S> |
annotateType(Annotation... annotation)
Adds annotations to the currently constructed type.
|
DynamicType.Builder<S> |
annotateType(AnnotationDescription... annotation)
Adds annotations to the currently constructed type.
|
protected InstrumentedType |
applyRecordedMembersTo(InstrumentedType instrumentedType)
Adds all fields and methods to an instrumented type.
|
DynamicType.Builder<S> |
attribute(TypeAttributeAppender attributeAppender)
Adds an attribute appender to the currently constructed type which will be applied on the creation of
the type.
|
DynamicType.Builder<S> |
bridgeMethodResolverFactory(BridgeMethodResolver.Factory bridgeMethodResolverFactory)
Defines a bridge method resolver factory to be applied to this type creation.
|
DynamicType.Builder<S> |
classFileVersion(ClassFileVersion classFileVersion)
Defines a class file format version for this builder for which the dynamic types should be created.
|
DynamicType.Builder<S> |
classVisitor(ClassVisitorWrapper classVisitorWrapper)
Adds an additional ASM
ClassVisitor to this builder which will be applied in
the construction process of this dynamic type. |
DynamicType.Builder.MatchedMethodInterception<S> |
constructor(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of constructors of this type for implementation.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
define(MethodDescription methodDescription)
Defines a new method or constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(Constructor<?> constructor)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(Iterable<Class<?>> parameterTypes,
int modifiers)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(Iterable<Class<?>> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(List<? extends TypeDescription> parameterTypes,
int modifiers)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(List<? extends TypeDescription> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineConstructor(MethodDescription methodDescription)
Defines a new constructor for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(Field field)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(FieldDescription fieldDescription)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(String name,
Class<?> fieldType,
int modifiers)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(String name,
Class<?> fieldType,
ModifierContributor.ForField... modifier)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(String name,
TypeDescription fieldTypeDescription,
int modifiers)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<S> |
defineField(String name,
TypeDescription fieldType,
ModifierContributor.ForField... modifier)
Defines a new field for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(Method method)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(MethodDescription methodDescription)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(String name,
Class<?> returnType,
List<Class<?>> parameterTypes,
int modifiers)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(String name,
Class<?> returnType,
List<Class<?>> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(String name,
TypeDescription returnType,
List<? extends TypeDescription> parameterTypes,
int modifiers)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<S> |
defineMethod(String name,
TypeDescription returnType,
List<? extends TypeDescription> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new method for this type.
|
boolean |
equals(Object other) |
int |
hashCode() |
DynamicType.Builder<S> |
ignoreMethods(ElementMatcher<? super MethodDescription> ignoredMethods)
Defines a matcher for methods that will be ignored for any interception attempt.
|
DynamicType.Builder.OptionalMatchedMethodInterception<S> |
implement(Class<?>... interfaceType)
Adds an interface to be implemented the created type.
|
DynamicType.Builder.OptionalMatchedMethodInterception<S> |
implement(TypeDescription... interfaceType)
Adds an interface to be implemented the created type.
|
DynamicType.Builder.MatchedMethodInterception<S> |
invokable(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of byte code level methods, i.e.
|
DynamicType.Builder.MatchedMethodInterception<S> |
invokable(LatentMethodMatcher methodMatcher)
Selects a set of byte code level methods, i.e.
|
protected abstract DynamicType.Builder<S> |
materialize(ClassFileVersion classFileVersion,
NamingStrategy namingStrategy,
AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
TypeDescription targetType,
List<TypeDescription> interfaceTypes,
int modifiers,
TypeAttributeAppender attributeAppender,
ElementMatcher<? super MethodDescription> ignoredMethods,
BridgeMethodResolver.Factory bridgeMethodResolverFactory,
ClassVisitorWrapper.Chain classVisitorWrapperChain,
FieldRegistry fieldRegistry,
MethodRegistry methodRegistry,
MethodLookupEngine.Factory methodLookupEngineFactory,
FieldAttributeAppender.Factory defaultFieldAttributeAppenderFactory,
MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory,
List<DynamicType.Builder.AbstractBase.FieldToken> fieldTokens,
List<DynamicType.Builder.AbstractBase.MethodToken> methodTokens)
Creates a new immutable type builder which represents the given arguments.
|
DynamicType.Builder.MatchedMethodInterception<S> |
method(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of methods of this type for instrumentation.
|
DynamicType.Builder<S> |
methodLookupEngine(MethodLookupEngine.Factory methodLookupEngineFactory)
Defines the use of a specific factory for a
MethodLookupEngine . |
DynamicType.Builder<S> |
modifiers(int modifiers)
Defines modifiers for the created dynamic type.
|
DynamicType.Builder<S> |
modifiers(ModifierContributor.ForType... modifier)
Defines modifiers for the created dynamic type.
|
DynamicType.Builder<S> |
name(AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy)
Defines a naming strategy for naming auxiliary types.
|
DynamicType.Builder<S> |
name(NamingStrategy namingStrategy)
Names the currently created dynamic type by the given naming strategy.
|
DynamicType.Builder<S> |
name(String name)
Names the currently created dynamic type by a fixed name.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
make
protected final ClassFileVersion classFileVersion
protected final NamingStrategy namingStrategy
protected final AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy
protected final TypeDescription targetType
protected final List<TypeDescription> interfaceTypes
protected final int modifiers
protected final TypeAttributeAppender attributeAppender
protected final ElementMatcher<? super MethodDescription> ignoredMethods
protected final BridgeMethodResolver.Factory bridgeMethodResolverFactory
protected final ClassVisitorWrapper.Chain classVisitorWrapperChain
protected final FieldRegistry fieldRegistry
protected final MethodRegistry methodRegistry
protected final MethodLookupEngine.Factory methodLookupEngineFactory
protected final FieldAttributeAppender.Factory defaultFieldAttributeAppenderFactory
protected final MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory
protected final List<DynamicType.Builder.AbstractBase.FieldToken> fieldTokens
protected final List<DynamicType.Builder.AbstractBase.MethodToken> methodTokens
protected AbstractBase(ClassFileVersion classFileVersion, NamingStrategy namingStrategy, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, TypeDescription targetType, List<TypeDescription> interfaceTypes, int modifiers, TypeAttributeAppender attributeAppender, ElementMatcher<? super MethodDescription> ignoredMethods, BridgeMethodResolver.Factory bridgeMethodResolverFactory, ClassVisitorWrapper.Chain classVisitorWrapperChain, FieldRegistry fieldRegistry, MethodRegistry methodRegistry, MethodLookupEngine.Factory methodLookupEngineFactory, FieldAttributeAppender.Factory defaultFieldAttributeAppenderFactory, MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory, List<DynamicType.Builder.AbstractBase.FieldToken> fieldTokens, List<DynamicType.Builder.AbstractBase.MethodToken> methodTokens)
classFileVersion
- The class file version for the created dynamic type.namingStrategy
- The naming strategy for naming the dynamic type.auxiliaryTypeNamingStrategy
- The naming strategy for naming auxiliary types of the dynamic type.targetType
- A description of the type that the dynamic type should represent.interfaceTypes
- A list of interfaces that should be implemented by the created dynamic type.modifiers
- The modifiers to be represented by the dynamic type.attributeAppender
- The attribute appender to apply onto the dynamic type that is created.ignoredMethods
- A matcher for determining methods that are to be ignored for instrumentation.bridgeMethodResolverFactory
- A factory for creating a bridge method resolver.classVisitorWrapperChain
- A chain of ASM class visitors to apply to the writing process.fieldRegistry
- The field registry to apply to the dynamic type creation.methodRegistry
- The method registry to apply to the dynamic type creation.methodLookupEngineFactory
- The method lookup engine factory to apply to the dynamic type creation.defaultFieldAttributeAppenderFactory
- The field attribute appender factory that should be applied by default if
no specific appender was specified for a given field.defaultMethodAttributeAppenderFactory
- The method attribute appender factory that should be applied by default
if no specific appender was specified for a given method.fieldTokens
- A list of field representations that were added explicitly to this
dynamic type.methodTokens
- A list of method representations that were added explicitly to this
dynamic type.protected InstrumentedType applyRecordedMembersTo(InstrumentedType instrumentedType)
instrumentedType
- The instrumented type that is basis of the alteration.public DynamicType.Builder.OptionalMatchedMethodInterception<S> implement(Class<?>... interfaceType)
DynamicType.Builder
implement
in interface DynamicType.Builder<S>
interfaceType
- The interface to implement.public DynamicType.Builder.FieldValueTarget<S> defineField(String name, Class<?> fieldType, ModifierContributor.ForField... modifier)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
name
- The name of the method.fieldType
- The type of this field where the current type can be represented by
TargetType
.modifier
- The modifiers for this method.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(String name, Class<?> returnType, List<Class<?>> parameterTypes, ModifierContributor.ForMethod... modifier)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
name
- The name of the method.returnType
- The return type of the method where the current type can be represented by
TargetType
.parameterTypes
- The parameter types of this method where the current type can be represented by
TargetType
.modifier
- The modifiers for this method.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(Iterable<Class<?>> parameterTypes, ModifierContributor.ForMethod... modifier)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifier
- The modifiers for this constructor.public DynamicType.Builder<S> classFileVersion(ClassFileVersion classFileVersion)
DynamicType.Builder
classFileVersion
in interface DynamicType.Builder<S>
classFileVersion
- The class format version for the dynamic type to implement.public DynamicType.Builder<S> name(String name)
DynamicType.Builder
name
in interface DynamicType.Builder<S>
name
- A fully qualified name to give to the created dynamic type.public DynamicType.Builder<S> name(NamingStrategy namingStrategy)
DynamicType.Builder
name
in interface DynamicType.Builder<S>
namingStrategy
- The naming strategy to apply.public DynamicType.Builder<S> name(AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy)
DynamicType.Builder
name
in interface DynamicType.Builder<S>
auxiliaryTypeNamingStrategy
- The naming strategy to use.public DynamicType.Builder<S> modifiers(ModifierContributor.ForType... modifier)
DynamicType.Builder
modifiers
in interface DynamicType.Builder<S>
modifier
- A collection of modifiers to be reflected by the created dynamic type.public DynamicType.Builder<S> modifiers(int modifiers)
DynamicType.Builder
modifiers
in interface DynamicType.Builder<S>
modifiers
- The modifiers to be reflected by the created dynamic type.public DynamicType.Builder<S> ignoreMethods(ElementMatcher<? super MethodDescription> ignoredMethods)
DynamicType.Builder
ignoreMethods
in interface DynamicType.Builder<S>
ignoredMethods
- A method matcher characterizing the methods to be ignored.public DynamicType.Builder<S> attribute(TypeAttributeAppender attributeAppender)
DynamicType.Builder
attribute
in interface DynamicType.Builder<S>
attributeAppender
- An attribute appender to be applied onto the currently created type.public DynamicType.Builder<S> annotateType(Annotation... annotation)
DynamicType.Builder
Note: The annotations will not be visible to
Implementation
s.annotateType
in interface DynamicType.Builder<S>
annotation
- The annotations to be added to the currently constructed type.public DynamicType.Builder<S> annotateType(AnnotationDescription... annotation)
DynamicType.Builder
Note: The annotations will not be visible to
Implementation
s.annotateType
in interface DynamicType.Builder<S>
annotation
- The annotations to be added to the currently constructed type.public DynamicType.Builder<S> classVisitor(ClassVisitorWrapper classVisitorWrapper)
DynamicType.Builder
ClassVisitor
to this builder which will be applied in
the construction process of this dynamic type.classVisitor
in interface DynamicType.Builder<S>
classVisitorWrapper
- The wrapper delegate for the ASM class visitor.public DynamicType.Builder<S> methodLookupEngine(MethodLookupEngine.Factory methodLookupEngineFactory)
DynamicType.Builder
MethodLookupEngine
.methodLookupEngine
in interface DynamicType.Builder<S>
methodLookupEngineFactory
- The factory to be used.public DynamicType.Builder<S> bridgeMethodResolverFactory(BridgeMethodResolver.Factory bridgeMethodResolverFactory)
DynamicType.Builder
bridgeMethodResolverFactory
in interface DynamicType.Builder<S>
bridgeMethodResolverFactory
- The bridge method resolver factory that is to be used.public DynamicType.Builder.OptionalMatchedMethodInterception<S> implement(TypeDescription... interfaceType)
DynamicType.Builder
implement
in interface DynamicType.Builder<S>
interfaceType
- A description of the interface to implement.public DynamicType.Builder.FieldValueTarget<S> defineField(String name, TypeDescription fieldType, ModifierContributor.ForField... modifier)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
name
- The name of the method.fieldType
- The type of this field where the current type can be represented by
TargetType
.modifier
- The modifiers for this method.public DynamicType.Builder.FieldValueTarget<S> defineField(String name, Class<?> fieldType, int modifiers)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
name
- The name of the method.fieldType
- The type of this field where the current type can be represented by
TargetType
.modifiers
- The modifiers for this method.public DynamicType.Builder.FieldValueTarget<S> defineField(String name, TypeDescription fieldTypeDescription, int modifiers)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
name
- The name of the method.fieldTypeDescription
- The type of this field where the current type can be represented by
TargetType
.modifiers
- The modifiers for this method.public DynamicType.Builder.FieldValueTarget<S> defineField(Field field)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
field
- The field that the generated type should imitate.public DynamicType.Builder.FieldValueTarget<S> defineField(FieldDescription fieldDescription)
DynamicType.Builder
defineField
in interface DynamicType.Builder<S>
fieldDescription
- The field that the generated type should imitate.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(String name, TypeDescription returnType, List<? extends TypeDescription> parameterTypes, ModifierContributor.ForMethod... modifier)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
name
- The name of the method.returnType
- A description of the return type of the method where the current type can be
represented by TargetType
.parameterTypes
- Descriptions of the parameter types of this method where the current type can be
represented by TargetType
.modifier
- The modifiers for this method.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(Method method)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
method
- The method that the generated type should imitate.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(MethodDescription methodDescription)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
methodDescription
- The method that the generated type should imitate.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(String name, Class<?> returnType, List<Class<?>> parameterTypes, int modifiers)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
name
- The name of the method.returnType
- The return type of the method where the current type can be represented by
TargetType
.parameterTypes
- The parameter types of this method where the current type can be represented by
TargetType
.modifiers
- The modifiers for this method.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineMethod(String name, TypeDescription returnType, List<? extends TypeDescription> parameterTypes, int modifiers)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.defineMethod
in interface DynamicType.Builder<S>
name
- The name of the method.returnType
- A description of the return type of the method where the current type can be
represented by TargetType
.parameterTypes
- Descriptions of the parameter types of this method where the current type can be
represented by TargetType
.modifiers
- The modifiers for this method.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(List<? extends TypeDescription> parameterTypes, ModifierContributor.ForMethod... modifier)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifier
- The modifiers for this constructor.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(Constructor<?> constructor)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Declared exceptions or annotations of the method are not copied and must be added manually.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
constructor
- The constructor for the generated type to imitate.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(MethodDescription methodDescription)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Declared exceptions or annotations of the method are not copied and must be added manually.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
methodDescription
- The constructor for the generated type to imitate.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(Iterable<Class<?>> parameterTypes, int modifiers)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifiers
- The modifiers for this constructor.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> defineConstructor(List<? extends TypeDescription> parameterTypes, int modifiers)
DynamicType.Builder
static
. Instead, a static type
initializer is added automatically if such an initializer is required. See
ElementMatchers.isTypeInitializer()
for a matcher for this initializer
which can be intercepted using
DynamicType.Builder.invokable(net.bytebuddy.matcher.ElementMatcher)
.
Note that a constructor's implementation must call another constructor of the same class or a constructor of its super class. This constructor call must be hardcoded inside of the constructor's method body. Before this constructor call is made, it is not legal to call any methods or to read any fields of the instance under construction.
defineConstructor
in interface DynamicType.Builder<S>
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifiers
- The modifiers for this constructor.public DynamicType.Builder.ExceptionDeclarableMethodInterception<S> define(MethodDescription methodDescription)
DynamicType.Builder
Note that a method definition overrides any method of identical signature that was defined in a super type what is only valid if the method is of at least broader visibility and if the overridden method is not
final
.define
in interface DynamicType.Builder<S>
methodDescription
- The method tor constructor hat the generated type should imitate.public DynamicType.Builder.MatchedMethodInterception<S> method(ElementMatcher<? super MethodDescription> methodMatcher)
DynamicType.Builder
method
in interface DynamicType.Builder<S>
methodMatcher
- A matcher describing the methods to be intercepted by this instrumentation.public DynamicType.Builder.MatchedMethodInterception<S> constructor(ElementMatcher<? super MethodDescription> methodMatcher)
DynamicType.Builder
constructor
in interface DynamicType.Builder<S>
methodMatcher
- A matcher describing the constructors to be intercepted by this implementation.public DynamicType.Builder.MatchedMethodInterception<S> invokable(ElementMatcher<? super MethodDescription> methodMatcher)
DynamicType.Builder
invokable
in interface DynamicType.Builder<S>
methodMatcher
- A matcher describing the byte code methods to be intercepted by this implementation.public DynamicType.Builder.MatchedMethodInterception<S> invokable(LatentMethodMatcher methodMatcher)
DynamicType.Builder
invokable
in interface DynamicType.Builder<S>
methodMatcher
- A latent matcher describing the byte code methods to be intercepted by this implementation.protected abstract DynamicType.Builder<S> materialize(ClassFileVersion classFileVersion, NamingStrategy namingStrategy, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, TypeDescription targetType, List<TypeDescription> interfaceTypes, int modifiers, TypeAttributeAppender attributeAppender, ElementMatcher<? super MethodDescription> ignoredMethods, BridgeMethodResolver.Factory bridgeMethodResolverFactory, ClassVisitorWrapper.Chain classVisitorWrapperChain, FieldRegistry fieldRegistry, MethodRegistry methodRegistry, MethodLookupEngine.Factory methodLookupEngineFactory, FieldAttributeAppender.Factory defaultFieldAttributeAppenderFactory, MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory, List<DynamicType.Builder.AbstractBase.FieldToken> fieldTokens, List<DynamicType.Builder.AbstractBase.MethodToken> methodTokens)
classFileVersion
- The class file version for the created dynamic type.namingStrategy
- The naming strategy for naming the dynamic type.auxiliaryTypeNamingStrategy
- The naming strategy for naming the auxiliary type of the dynamic type.targetType
- A description of the type that the dynamic type should represent.interfaceTypes
- A list of interfaces that should be implemented by the created dynamic type.modifiers
- The modifiers to be represented by the dynamic type.attributeAppender
- The attribute appender to apply onto the dynamic type that is created.ignoredMethods
- A matcher for determining methods that are to be ignored for implementation.bridgeMethodResolverFactory
- A factory for creating a bridge method resolver.classVisitorWrapperChain
- A chain of ASM class visitors to apply to the writing process.fieldRegistry
- The field registry to apply to the dynamic type creation.methodRegistry
- The method registry to apply to the dynamic type creation.methodLookupEngineFactory
- The method lookup engine factory to apply to the dynamic type creation.defaultFieldAttributeAppenderFactory
- The field attribute appender factory that should be applied by default if
no specific appender was specified for a given field.defaultMethodAttributeAppenderFactory
- The method attribute appender factory that should be applied by default
if no specific appender was specified for a given method.fieldTokens
- A list of field representations that were added explicitly to this
dynamic type.methodTokens
- A list of method representations that were added explicitly to this
dynamic type.Copyright © 2014–2015. All rights reserved.