Class MethodAttributeAppender.Explicit
java.lang.Object
net.bytebuddy.implementation.attribute.MethodAttributeAppender.Explicit
- All Implemented Interfaces:
MethodAttributeAppender
,MethodAttributeAppender.Factory
- Enclosing interface:
- MethodAttributeAppender
@Enhance
public static class MethodAttributeAppender.Explicit
extends Object
implements MethodAttributeAppender, MethodAttributeAppender.Factory
Appends an annotation to a method or method parameter. The visibility of the annotation is determined by the
annotation type's
RetentionPolicy
annotation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
Represents the target on which this method attribute appender should write its annotations to.Nested classes/interfaces inherited from interface net.bytebuddy.implementation.attribute.MethodAttributeAppender
MethodAttributeAppender.Compound, MethodAttributeAppender.Explicit, MethodAttributeAppender.Factory, MethodAttributeAppender.ForInstrumentedMethod, MethodAttributeAppender.ForReceiverType, MethodAttributeAppender.NoOp
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.attribute.MethodAttributeAppender.Factory
MethodAttributeAppender.Factory.Compound
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<? extends AnnotationDescription>
the annotations this method attribute appender is writing to its target.private final MethodAttributeAppender.Explicit.Target
The target to which the annotations are written to. -
Constructor Summary
ConstructorsModifierConstructorDescriptionExplicit
(int parameterIndex, List<? extends AnnotationDescription> annotations) Creates a new appender for appending an annotation to a method.Explicit
(List<? extends AnnotationDescription> annotations) Creates a new appender for appending an annotation to a method.protected
Explicit
(MethodAttributeAppender.Explicit.Target target, List<? extends AnnotationDescription> annotations) Creates an explicit annotation appender for a either a method or one of its parameters.. -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(org.objectweb.asm.MethodVisitor methodVisitor, MethodDescription methodDescription, AnnotationValueFilter annotationValueFilter) Applies this attribute appender to a given method visitor.make
(TypeDescription typeDescription) Returns a method attribute appender that is applicable for a given type description.of
(MethodDescription methodDescription) Creates a method attribute appender factory that writes all annotations of a given method, both the method annotations themselves and all annotations that are defined for every parameter.ofMethodAnnotations
(MethodDescription methodDescription) Creates a method attribute appender factory that writes all method annotations that are defined on the given method.ofParameterAnnotations
(MethodDescription methodDescription) Creates a method attribute appender factory that writes all annotations that are defined for every parameter of the given method.
-
Field Details
-
target
The target to which the annotations are written to. -
annotations
the annotations this method attribute appender is writing to its target.
-
-
Constructor Details
-
Explicit
Creates a new appender for appending an annotation to a method.- Parameters:
parameterIndex
- The index of the parameter to which the annotations should be written.annotations
- The annotations that should be written.
-
Explicit
Creates a new appender for appending an annotation to a method.- Parameters:
annotations
- The annotations that should be written.
-
Explicit
protected Explicit(MethodAttributeAppender.Explicit.Target target, List<? extends AnnotationDescription> annotations) Creates an explicit annotation appender for a either a method or one of its parameters..- Parameters:
target
- The target to which the annotation should be written to.annotations
- The annotations to write.
-
-
Method Details
-
of
Creates a method attribute appender factory that writes all annotations of a given method, both the method annotations themselves and all annotations that are defined for every parameter.- Parameters:
methodDescription
- The method from which to extract the annotations.- Returns:
- A method attribute appender factory for an appender that writes all annotations of the supplied method.
-
ofMethodAnnotations
public static MethodAttributeAppender.Factory ofMethodAnnotations(MethodDescription methodDescription) Creates a method attribute appender factory that writes all method annotations that are defined on the given method.- Parameters:
methodDescription
- The method from which to extract the method annotations.- Returns:
- A method attribute appender factory for an appender that writes all method annotations of the supplied method.
-
ofParameterAnnotations
public static MethodAttributeAppender.Factory ofParameterAnnotations(MethodDescription methodDescription) Creates a method attribute appender factory that writes all annotations that are defined for every parameter of the given method.- Parameters:
methodDescription
- The method from which to extract the parameter annotations.- Returns:
- A method attribute appender factory for an appender that writes all parameter annotations of the supplied method.
-
make
Returns a method attribute appender that is applicable for a given type description.- Specified by:
make
in interfaceMethodAttributeAppender.Factory
- Parameters:
typeDescription
- The type for which a method attribute appender is to be applied for.- Returns:
- The method attribute appender which should be applied for the given type.
-
apply
public void apply(org.objectweb.asm.MethodVisitor methodVisitor, MethodDescription methodDescription, AnnotationValueFilter annotationValueFilter) Applies this attribute appender to a given method visitor.- Specified by:
apply
in interfaceMethodAttributeAppender
- Parameters:
methodVisitor
- The method visitor to which the attributes that are represented by this attribute appender are written to.methodDescription
- The description of the method for which the given method visitor creates an instrumentation for.annotationValueFilter
- The annotation value filter to apply when the annotations are written.
-