Package net.bytebuddy.asm
Class Advice.WithCustomMapping
- java.lang.Object
-
- net.bytebuddy.asm.Advice.WithCustomMapping
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WithCustomMapping()
Creates a new custom mapping builder step without including any custom mappings.protected
WithCustomMapping(java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,Advice.OffsetMapping.Factory<?>> offsetMappings)
Creates a new custom mapping builder step with the given custom mappings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.Class<?> value)
Binds the supplied annotation to the supplied type constant.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.Enum<?> value)
Binds the supplied annotation to the supplied enumeration constant.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.Object value)
Binds the supplied annotation to a type constant of the supplied value.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.reflect.Constructor<?> constructor, int index)
Binds the supplied annotation to the supplied parameter's argument.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.reflect.Field field)
Binds the supplied annotation to the value of the supplied field.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, java.lang.reflect.Method method, int index)
Binds the supplied annotation to the supplied parameter's argument.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, Advice.OffsetMapping offsetMapping)
Binds the supplied annotation to the annotation's property of the specified name.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, EnumerationDescription value)
Binds the supplied annotation to the supplied enumeration constant.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, FieldDescription fieldDescription)
Binds the supplied annotation to the value of the supplied field.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, ParameterDescription parameterDescription)
Binds the supplied annotation to the supplied parameter's argument.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, TypeDescription value)
Binds the supplied annotation to the supplied type constant.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, StackManipulation stackManipulation, java.lang.reflect.Type targetType)
Binds the supplied annotation to the annotation's property of the specified name.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbind(java.lang.Class<T> type, StackManipulation stackManipulation, TypeDescription.Generic targetType)
Binds the supplied annotation to the annotation's property of the specified name.Advice.WithCustomMapping
bind(Advice.OffsetMapping.Factory<?> offsetMapping)
Binds an annotation to a dynamically computed value.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbindProperty(java.lang.Class<T> type, java.lang.String property)
Binds the supplied annotation to the annotation's property of the specified name.<T extends java.lang.annotation.Annotation>
Advice.WithCustomMappingbindSerialized(java.lang.Class<T> type, java.io.Serializable value)
Binds the supplied annotation to the supplied fixed value.<T extends java.lang.annotation.Annotation,S extends java.io.Serializable>
Advice.WithCustomMappingbindSerialized(java.lang.Class<T> type, S value, java.lang.Class<? super S> targetType)
Binds the supplied annotation to the supplied fixed value.Advice
to(java.lang.Class<?> advice)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(java.lang.Class<?> enterAdvice, java.lang.Class<?> exitAdvice)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(java.lang.Class<?> enterAdvice, java.lang.Class<?> exitAdvice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(java.lang.Class<?> advice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(TypeDescription enterAdvice, TypeDescription exitAdvice)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(TypeDescription enterAdvice, TypeDescription exitAdvice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.Advice
to(TypeDescription advice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.
-
-
-
Constructor Detail
-
WithCustomMapping
protected WithCustomMapping()
Creates a new custom mapping builder step without including any custom mappings.
-
WithCustomMapping
protected WithCustomMapping(java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,Advice.OffsetMapping.Factory<?>> offsetMappings)
Creates a new custom mapping builder step with the given custom mappings.- Parameters:
offsetMappings
- A map containing dynamically computed constant pool values that are mapped by their triggering annotation type.
-
-
Method Detail
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.Object value)
Binds the supplied annotation to a type constant of the supplied value. Constants can be strings, method handles, method types and any primitive or the valuenull
.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to the annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.reflect.Field field)
Binds the supplied annotation to the value of the supplied field. The field must be visible by the instrumented type and must be declared by a super type of the instrumented field.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.field
- The field to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, FieldDescription fieldDescription)
Binds the supplied annotation to the value of the supplied field. The field must be visible by the instrumented type and must be declared by a super type of the instrumented field. The binding is defined as read-only and applied static typing.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.fieldDescription
- The field to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.reflect.Method method, int index)
Binds the supplied annotation to the supplied parameter's argument.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.method
- The method that defines the parameter.index
- The index of the parameter.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.reflect.Constructor<?> constructor, int index)
Binds the supplied annotation to the supplied parameter's argument.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constructor
- The constructor that defines the parameter.index
- The index of the parameter.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, ParameterDescription parameterDescription)
Binds the supplied annotation to the supplied parameter's argument. The binding is declared read-only and applies static typing.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.parameterDescription
- The parameter for which to bind an argument.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.Class<?> value)
Binds the supplied annotation to the supplied type constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The type constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, TypeDescription value)
Binds the supplied annotation to the supplied type constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The type constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, java.lang.Enum<?> value)
Binds the supplied annotation to the supplied enumeration constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The enumeration constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, EnumerationDescription value)
Binds the supplied annotation to the supplied enumeration constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The enumeration constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindSerialized
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bindSerialized(java.lang.Class<T> type, java.io.Serializable value)
Binds the supplied annotation to the supplied fixed value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindSerialized
public <T extends java.lang.annotation.Annotation,S extends java.io.Serializable> Advice.WithCustomMapping bindSerialized(java.lang.Class<T> type, S value, java.lang.Class<? super S> targetType)
Binds the supplied annotation to the supplied fixed value.- Type Parameters:
T
- The annotation type.S
- The type of the serialized instance.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to this annotation.targetType
- The type ofvalue
as which the instance should be treated.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindProperty
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bindProperty(java.lang.Class<T> type, java.lang.String property)
Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.property
- The name of the annotation property to be bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, StackManipulation stackManipulation, java.lang.reflect.Type targetType)
Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.stackManipulation
- The stack manipulation loading the bound value.targetType
- The type of the loaded value.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, StackManipulation stackManipulation, TypeDescription.Generic targetType)
Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.stackManipulation
- The stack manipulation loading the bound value.targetType
- The type of the loaded value.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends java.lang.annotation.Annotation> Advice.WithCustomMapping bind(java.lang.Class<T> type, Advice.OffsetMapping offsetMapping)
Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.offsetMapping
- The offset mapping being bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public Advice.WithCustomMapping bind(Advice.OffsetMapping.Factory<?> offsetMapping)
Binds an annotation to a dynamically computed value. Whenever theAdvice
component discovers the given annotation on a parameter of an advice method, the dynamic value is asked to provide a value that is then assigned to the parameter in question.- Parameters:
offsetMapping
- The dynamic value that is computed for binding the parameter to a value.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
to
public Advice to(java.lang.Class<?> advice)
Implements advice where every matched method is advised by the given type's advisory methods. The advices binary representation is accessed by querying the class loader of the supplied class for a class file.- Parameters:
advice
- The type declaring the advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(java.lang.Class<?> advice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
advice
- The type declaring the advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(TypeDescription advice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
advice
- A description of the type declaring the advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(java.lang.Class<?> enterAdvice, java.lang.Class<?> exitAdvice)
Implements advice where every matched method is advised by the given type's advisory methods. The advices binary representation is accessed by querying the class loader of the supplied class for a class file.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(java.lang.Class<?> enterAdvice, java.lang.Class<?> exitAdvice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(TypeDescription enterAdvice, TypeDescription exitAdvice)
Implements advice where every matched method is advised by the given type's advisory methods. Using this method, a non-operational class file locator is specified for the advice target. This implies that only advice targets with the inline target set tofalse
are resolvable by the returned instance.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(TypeDescription enterAdvice, TypeDescription exitAdvice, ClassFileLocator classFileLocator)
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
-