T
- 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 static interface DynamicType.Builder<T>
Modifier and Type | Interface and Description |
---|---|
static class |
DynamicType.Builder.AbstractBase<S>
An abstract base implementation for a dynamic type builder.
|
static interface |
DynamicType.Builder.ExceptionDeclarableMethodInterception<S>
Defines an instrumentation for a method that was added to this instrumentation and allows to include
exception declarations for the newly defined method.
|
static interface |
DynamicType.Builder.FieldAnnotationTarget<S>
A builder to which a field was just added such that attribute changes can be applied to this field.
|
static interface |
DynamicType.Builder.FieldValueTarget<S>
A builder to which a field was just added such that default values can be defined for the field.
|
static interface |
DynamicType.Builder.MatchedMethodInterception<T>
Defines an instrumentation for a method that was added to this instrumentation or a to method selection
of existing methods.
|
static interface |
DynamicType.Builder.MethodAnnotationTarget<S>
A builder to which a method was just added or an interception for existing methods was specified such that
attribute changes can be applied to these methods.
|
static interface |
DynamicType.Builder.OptionalMatchedMethodInterception<S>
An optional matched method interception allows to define an interception without requiring the definition
of an implementation.
|
Modifier and Type | Method and Description |
---|---|
DynamicType.Builder<T> |
annotateType(Annotation... annotation)
Adds annotations to the currently constructed type.
|
DynamicType.Builder<T> |
attribute(TypeAttributeAppender attributeAppender)
Adds an attribute appender to the currently constructed type which will be applied on the creation of
the type.
|
DynamicType.Builder<T> |
bridgeMethodResolverFactory(BridgeMethodResolver.Factory bridgeMethodResolverFactory)
Defines a bridge method resolver factory to be applied to this type creation.
|
DynamicType.Builder<T> |
classFileVersion(ClassFileVersion classFileVersion)
Defines a class file format version for this builder for which the dynamic types should be created.
|
DynamicType.Builder<T> |
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<T> |
constructor(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of constructors of this type for instrumentation.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Constructor<?> constructor)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Iterable<Class<?>> parameterTypes,
int modifiers)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Iterable<Class<?>> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(List<? extends TypeDescription> parameterTypes,
int modifiers)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(List<? extends TypeDescription> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new constructor for this type.
|
DynamicType.Builder.FieldValueTarget<T> |
defineField(Field field)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<T> |
defineField(String name,
Class<?> fieldType,
int modifiers)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<T> |
defineField(String name,
Class<?> fieldType,
ModifierContributor.ForField... modifier)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<T> |
defineField(String name,
TypeDescription fieldTypeDescription,
int modifiers)
Defines a new field for this type.
|
DynamicType.Builder.FieldValueTarget<T> |
defineField(String name,
TypeDescription fieldTypeDescription,
ModifierContributor.ForField... modifier)
Defines a new field for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(Method method)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
Class<?> returnType,
List<Class<?>> parameterTypes,
int modifiers)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
Class<?> returnType,
List<Class<?>> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
TypeDescription returnType,
List<? extends TypeDescription> parameterTypes,
int modifiers)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
TypeDescription returnType,
List<? extends TypeDescription> parameterTypes,
ModifierContributor.ForMethod... modifier)
Defines a new method for this type.
|
DynamicType.Builder<T> |
ignoreMethods(ElementMatcher<? super MethodDescription> ignoredMethods)
Defines a matcher for methods that will be ignored for any interception attempt.
|
DynamicType.Builder.OptionalMatchedMethodInterception<T> |
implement(Class<?>... interfaceType)
Adds an interface to be implemented the created type.
|
DynamicType.Builder.OptionalMatchedMethodInterception<T> |
implement(TypeDescription... interfaceType)
Adds an interface to be implemented the created type.
|
DynamicType.Builder.MatchedMethodInterception<T> |
invokable(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of byte code methods of this type for instrumentation.
|
DynamicType.Unloaded<T> |
make()
Creates the dynamic type without loading it.
|
DynamicType.Builder.MatchedMethodInterception<T> |
method(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of methods of this type for instrumentation.
|
DynamicType.Builder<T> |
methodLookupEngine(MethodLookupEngine.Factory methodLookupEngineFactory)
Defines the use of a specific factory for a
MethodLookupEngine . |
DynamicType.Builder<T> |
modifiers(int modifiers)
Defines modifiers for the created dynamic type.
|
DynamicType.Builder<T> |
modifiers(ModifierContributor.ForType... modifier)
Defines modifiers for the created dynamic type.
|
DynamicType.Builder<T> |
name(NamingStrategy namingStrategy)
Names the currently created dynamic type by the given naming strategy.
|
DynamicType.Builder<T> |
name(String name)
Names the currently created dynamic type by a fixed name.
|
DynamicType.Builder<T> classFileVersion(ClassFileVersion classFileVersion)
classFileVersion
- The class format version for the dynamic type to implement.DynamicType.Builder.OptionalMatchedMethodInterception<T> implement(Class<?>... interfaceType)
interfaceType
- The interface to implement.DynamicType.Builder.OptionalMatchedMethodInterception<T> implement(TypeDescription... interfaceType)
interfaceType
- A description of the interface to implement.DynamicType.Builder<T> name(String name)
name
- A fully qualified name to give to the created dynamic type.DynamicType.Builder<T> name(NamingStrategy namingStrategy)
namingStrategy
- The naming strategy to apply.DynamicType.Builder<T> modifiers(ModifierContributor.ForType... modifier)
modifier
- A collection of modifiers to be reflected by the created dynamic type.DynamicType.Builder<T> modifiers(int modifiers)
modifiers
- The modifiers to be reflected by the created dynamic type.DynamicType.Builder<T> ignoreMethods(ElementMatcher<? super MethodDescription> ignoredMethods)
ignoredMethods
- A method matcher characterizing the methods to be ignored.DynamicType.Builder<T> attribute(TypeAttributeAppender attributeAppender)
attributeAppender
- An attribute appender to be applied onto the currently created type.DynamicType.Builder<T> annotateType(Annotation... annotation)
Note: The annotations will not be visible to
Instrumentation
s.annotation
- The annotations to be added to the currently constructed type.DynamicType.Builder<T> classVisitor(ClassVisitorWrapper classVisitorWrapper)
ClassVisitor
to this builder which will be applied in
the construction process of this dynamic type.classVisitorWrapper
- The wrapper delegate for the ASM class visitor.DynamicType.Builder<T> bridgeMethodResolverFactory(BridgeMethodResolver.Factory bridgeMethodResolverFactory)
bridgeMethodResolverFactory
- The bridge method resolver factory that is to be used.DynamicType.Builder<T> methodLookupEngine(MethodLookupEngine.Factory methodLookupEngineFactory)
MethodLookupEngine
.methodLookupEngineFactory
- The factory to be used.DynamicType.Builder.FieldValueTarget<T> defineField(String name, Class<?> fieldType, ModifierContributor.ForField... modifier)
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.DynamicType.Builder.FieldValueTarget<T> defineField(String name, TypeDescription fieldTypeDescription, ModifierContributor.ForField... modifier)
name
- The name of the method.fieldTypeDescription
- The type of this field where the current type can be represented by
TargetType
.modifier
- The modifiers for this method.DynamicType.Builder.FieldValueTarget<T> defineField(String name, Class<?> fieldType, int modifiers)
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.DynamicType.Builder.FieldValueTarget<T> defineField(String name, TypeDescription fieldTypeDescription, int modifiers)
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.DynamicType.Builder.FieldValueTarget<T> defineField(Field field)
field
- The field that the generated type should imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(String name, Class<?> returnType, List<Class<?>> parameterTypes, ModifierContributor.ForMethod... modifier)
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
.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.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(String name, TypeDescription returnType, List<? extends TypeDescription> parameterTypes, ModifierContributor.ForMethod... modifier)
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
.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.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(String name, Class<?> returnType, List<Class<?>> parameterTypes, int modifiers)
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
.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.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(String name, TypeDescription returnType, List<? extends TypeDescription> parameterTypes, int modifiers)
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
.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.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(Method method)
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
.method
- The method that the generated type should imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(Iterable<Class<?>> parameterTypes, ModifierContributor.ForMethod... modifier)
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
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.
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifier
- The modifiers for this constructor.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(List<? extends TypeDescription> parameterTypes, ModifierContributor.ForMethod... modifier)
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
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.
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifier
- The modifiers for this constructor.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(Iterable<Class<?>> parameterTypes, int modifiers)
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
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.
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifiers
- The modifiers for this constructor.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(List<? extends TypeDescription> parameterTypes, int modifiers)
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
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.
parameterTypes
- The parameter types of this constructor where the current type can be represented by
TargetType
.modifiers
- The modifiers for this constructor.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(Constructor<?> constructor)
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
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.
constructor
- The constructor for the generated type to imitate.DynamicType.Builder.MatchedMethodInterception<T> method(ElementMatcher<? super MethodDescription> methodMatcher)
methodMatcher
- A matcher describing the methods to be intercepted by this instrumentation.DynamicType.Builder.MatchedMethodInterception<T> constructor(ElementMatcher<? super MethodDescription> methodMatcher)
methodMatcher
- A matcher describing the constructors to be intercepted by this instrumentation.DynamicType.Builder.MatchedMethodInterception<T> invokable(ElementMatcher<? super MethodDescription> methodMatcher)
methodMatcher
- A matcher describing the byte code methods to be intercepted by this instrumentation.DynamicType.Unloaded<T> make()
Copyright © 2014–2015. All rights reserved.