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 implementation 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<S>
Defines an implementation 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> |
annotateType(AnnotationDescription... annotation)
Adds annotations to the currently constructed type.
|
DynamicType.Builder<T> |
annotateType(Collection<? extends AnnotationDescription> annotations)
Adds annotations to the currently constructed type.
|
DynamicType.Builder<T> |
annotateType(Iterable<? extends Annotation> annotations)
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> |
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 implementation.
|
DynamicType.Builder<T> |
context(Implementation.Context.Factory implementationContextFactory)
Defines a factory for creating an implementation context.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
define(MethodDescription methodDescription)
Defines a new method or constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Constructor<?> constructor)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Iterable<? extends Class<?>> parameterTypes,
int modifiers)
Defines a new constructor for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineConstructor(Iterable<? extends 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.ExceptionDeclarableMethodInterception<T> |
defineConstructor(MethodDescription methodDescription)
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(FieldDescription fieldDescription)
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(MethodDescription methodDescription)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
Class<?> returnType,
List<? extends Class<?>> parameterTypes,
int modifiers)
Defines a new method for this type.
|
DynamicType.Builder.ExceptionDeclarableMethodInterception<T> |
defineMethod(String name,
Class<?> returnType,
List<? extends 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 the given interfaces to be implemented by the created type.
|
DynamicType.Builder.OptionalMatchedMethodInterception<T> |
implement(Collection<? extends TypeDescription> interfaceTypes)
Adds the given interfaces to be implemented by the created type.
|
DynamicType.Builder.OptionalMatchedMethodInterception<T> |
implement(Iterable<? extends Class<?>> interfaceTypes)
Adds the given interfaces to be implemented by the created type.
|
DynamicType.Builder.OptionalMatchedMethodInterception<T> |
implement(TypeDescription... interfaceType)
Adds the given interfaces to be implemented by the created type.
|
DynamicType.Builder<T> |
initialize(ByteCodeAppender byteCodeAppender)
Defines an explicit type initialization block that is appended to any potentially existing
type initializer.
|
DynamicType.Builder.MatchedMethodInterception<T> |
invokable(ElementMatcher<? super MethodDescription> methodMatcher)
Selects a set of byte code level methods, i.e.
|
DynamicType.Builder.MatchedMethodInterception<T> |
invokable(LatentMethodMatcher methodMatcher)
Selects a set of byte code level methods, i.e.
|
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> |
methodGraphCompiler(MethodGraph.Compiler methodGraphCompiler)
Defines the given method graph compiler to be used for analyzing the structure of types.
|
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(AuxiliaryType.NamingStrategy namingStrategy)
Defines a naming strategy for naming auxiliary types.
|
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 interfaces to implement.DynamicType.Builder.OptionalMatchedMethodInterception<T> implement(Iterable<? extends Class<?>> interfaceTypes)
interfaceTypes
- The interfaces to implement.DynamicType.Builder.OptionalMatchedMethodInterception<T> implement(TypeDescription... interfaceType)
interfaceType
- A description of the interfaces to implement.DynamicType.Builder.OptionalMatchedMethodInterception<T> implement(Collection<? extends TypeDescription> interfaceTypes)
interfaceTypes
- A description of the interfaces 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> name(AuxiliaryType.NamingStrategy namingStrategy)
namingStrategy
- The naming strategy to use.DynamicType.Builder<T> context(Implementation.Context.Factory implementationContextFactory)
implementationContextFactory
- The implementation context factory to use.DynamicType.Builder<T> initialize(ByteCodeAppender byteCodeAppender)
byteCodeAppender
- The byte code appender that represents the code. This initializer must not return.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
Implementation
s.annotation
- The annotations to be added to the currently constructed type.DynamicType.Builder<T> annotateType(Iterable<? extends Annotation> annotations)
Note: The annotations will not be visible to
Implementation
s.annotations
- The annotations to be added to the currently constructed type.DynamicType.Builder<T> annotateType(AnnotationDescription... annotation)
Note: The annotations will not be visible to
Implementation
s.annotation
- The annotations to be added to the currently constructed type.DynamicType.Builder<T> annotateType(Collection<? extends AnnotationDescription> annotations)
Note: The annotations will not be visible to
Implementation
s.annotations
- 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> methodGraphCompiler(MethodGraph.Compiler methodGraphCompiler)
methodGraphCompiler
- The method graph compiler 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.FieldValueTarget<T> defineField(FieldDescription fieldDescription)
fieldDescription
- The field that the generated type should imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineMethod(String name, Class<?> returnType, List<? extends 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<? extends 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> defineMethod(MethodDescription methodDescription)
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
.methodDescription
- The method that the generated type should imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(Iterable<? extends 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<? extends 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)
.
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.
constructor
- The constructor for the generated type to imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> defineConstructor(MethodDescription methodDescription)
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)
.
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.
methodDescription
- The constructor for the generated type to imitate.DynamicType.Builder.ExceptionDeclarableMethodInterception<T> define(MethodDescription methodDescription)
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
.methodDescription
- The method tor constructor hat the generated type should 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 implementation.DynamicType.Builder.MatchedMethodInterception<T> invokable(ElementMatcher<? super MethodDescription> methodMatcher)
methodMatcher
- A matcher describing the byte code methods to be intercepted by this implementation.DynamicType.Builder.MatchedMethodInterception<T> invokable(LatentMethodMatcher methodMatcher)
methodMatcher
- A latent matcher describing the byte code methods to be intercepted by this implementation.DynamicType.Unloaded<T> make()
Copyright © 2014–2015. All rights reserved.