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 java.lang.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'sRetentionPolicy
annotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
MethodAttributeAppender.Explicit.Target
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
Fields Modifier and Type Field Description private java.util.List<? extends AnnotationDescription>
annotations
the annotations this method attribute appender is writing to its target.private MethodAttributeAppender.Explicit.Target
target
The target to which the annotations are written to.
-
Constructor Summary
Constructors Modifier Constructor Description Explicit(int parameterIndex, java.util.List<? extends AnnotationDescription> annotations)
Creates a new appender for appending an annotation to a method.Explicit(java.util.List<? extends AnnotationDescription> annotations)
Creates a new appender for appending an annotation to a method.protected
Explicit(MethodAttributeAppender.Explicit.Target target, java.util.List<? extends AnnotationDescription> annotations)
Creates an explicit annotation appender for a either a method or one of its parameters..
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(org.objectweb.asm.MethodVisitor methodVisitor, MethodDescription methodDescription, AnnotationValueFilter annotationValueFilter)
Applies this attribute appender to a given method visitor.MethodAttributeAppender
make(TypeDescription typeDescription)
Returns a method attribute appender that is applicable for a given type description.static MethodAttributeAppender.Factory
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.static MethodAttributeAppender.Factory
ofMethodAnnotations(MethodDescription methodDescription)
Creates a method attribute appender factory that writes all method annotations that are defined on the given method.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.
-
-
-
Field Detail
-
target
private final MethodAttributeAppender.Explicit.Target target
The target to which the annotations are written to.
-
annotations
private final java.util.List<? extends AnnotationDescription> annotations
the annotations this method attribute appender is writing to its target.
-
-
Constructor Detail
-
Explicit
public Explicit(int parameterIndex, java.util.List<? extends AnnotationDescription> annotations)
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
public Explicit(java.util.List<? extends AnnotationDescription> annotations)
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, java.util.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 Detail
-
of
public static MethodAttributeAppender.Factory 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.- 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
public MethodAttributeAppender make(TypeDescription typeDescription)
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.
-
-