Package net.bytebuddy.asm
Class MemberAttributeExtension.ForMethod
java.lang.Object
net.bytebuddy.asm.MemberAttributeExtension<MethodAttributeAppender.Factory>
net.bytebuddy.asm.MemberAttributeExtension.ForMethod
- All Implemented Interfaces:
AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
- Enclosing class:
- MemberAttributeExtension<T>
public static class MemberAttributeExtension.ForMethod
extends MemberAttributeExtension<MethodAttributeAppender.Factory>
implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
A visitor that adds attributes to a method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A method visitor to apply a method attribute appender.Nested classes/interfaces inherited from class net.bytebuddy.asm.MemberAttributeExtension
MemberAttributeExtension.ForField, MemberAttributeExtension.ForMethod
-
Field Summary
Fields inherited from class net.bytebuddy.asm.MemberAttributeExtension
annotationValueFilterFactory, attributeAppenderFactory
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a method attribute extension.ForMethod
(AnnotationValueFilter.Factory annotationValueFilterFactory) Creates a method attribute extension.protected
ForMethod
(AnnotationValueFilter.Factory annotationValueFilterFactory, MethodAttributeAppender.Factory attributeAppenderFactory) Creates a method attribute extension. -
Method Summary
Modifier and TypeMethodDescriptionannotateMethod
(Annotation... annotation) Appends the supplied annotations.annotateMethod
(Collection<? extends AnnotationDescription> annotations) Appends the supplied annotations.annotateMethod
(List<? extends Annotation> annotations) Appends the supplied annotations.annotateMethod
(AnnotationDescription... annotation) Appends the supplied annotations.annotateParameter
(int index, Annotation... annotation) Appends the supplied annotations to the parameter at the given index.annotateParameter
(int index, Collection<? extends AnnotationDescription> annotations) Appends the supplied annotations to the parameter at the given index.annotateParameter
(int index, List<? extends Annotation> annotations) Appends the supplied annotations to the parameter at the given index.annotateParameter
(int index, AnnotationDescription... annotation) Appends the supplied annotations to the parameter at the given index.attribute
(MethodAttributeAppender.Factory attributeAppenderFactory) Appends the supplied method attribute appender factory.on
(ElementMatcher<? super MethodDescription> matcher) Applies this attribute extension on any method or constructor that matches the supplied matcher.org.objectweb.asm.MethodVisitor
wrap
(TypeDescription instrumentedType, MethodDescription instrumentedMethod, org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, TypePool typePool, int writerFlags, int readerFlags) Wraps a method visitor.
-
Constructor Details
-
ForMethod
public ForMethod()Creates a method attribute extension. -
ForMethod
Creates a method attribute extension.- Parameters:
annotationValueFilterFactory
- The annotation value filter factory to apply.
-
ForMethod
protected ForMethod(AnnotationValueFilter.Factory annotationValueFilterFactory, MethodAttributeAppender.Factory attributeAppenderFactory) Creates a method attribute extension.- Parameters:
annotationValueFilterFactory
- The annotation value filter factory to apply.attributeAppenderFactory
- The method attribute appender factory to use.
-
-
Method Details
-
annotateMethod
Appends the supplied annotations.- Parameters:
annotation
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateMethod
Appends the supplied annotations.- Parameters:
annotations
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateMethod
Appends the supplied annotations.- Parameters:
annotation
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateMethod
public MemberAttributeExtension.ForMethod annotateMethod(Collection<? extends AnnotationDescription> annotations) Appends the supplied annotations.- Parameters:
annotations
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateParameter
Appends the supplied annotations to the parameter at the given index.- Parameters:
index
- The parameter index.annotation
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateParameter
public MemberAttributeExtension.ForMethod annotateParameter(int index, List<? extends Annotation> annotations) Appends the supplied annotations to the parameter at the given index.- Parameters:
index
- The parameter index.annotations
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateParameter
public MemberAttributeExtension.ForMethod annotateParameter(int index, AnnotationDescription... annotation) Appends the supplied annotations to the parameter at the given index.- Parameters:
index
- The parameter index.annotation
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
annotateParameter
public MemberAttributeExtension.ForMethod annotateParameter(int index, Collection<? extends AnnotationDescription> annotations) Appends the supplied annotations to the parameter at the given index.- Parameters:
index
- The parameter index.annotations
- The annotations to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
attribute
public MemberAttributeExtension.ForMethod attribute(MethodAttributeAppender.Factory attributeAppenderFactory) Appends the supplied method attribute appender factory.- Parameters:
attributeAppenderFactory
- The attribute appender factory to append.- Returns:
- A new method attribute extension that appends any previously registered attributes and the supplied annotations.
-
wrap
public org.objectweb.asm.MethodVisitor wrap(TypeDescription instrumentedType, MethodDescription instrumentedMethod, org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, TypePool typePool, int writerFlags, int readerFlags) Wraps a method visitor.- Specified by:
wrap
in interfaceAsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
- Parameters:
instrumentedType
- The instrumented type.instrumentedMethod
- The method that is currently being defined.methodVisitor
- The original field visitor that defines the given method.implementationContext
- The implementation context to use.typePool
- The type pool to use.writerFlags
- The ASMClassWriter
reader flags to consider.readerFlags
- The ASMClassReader
reader flags to consider.- Returns:
- The wrapped method visitor.
-
on
Applies this attribute extension on any method or constructor that matches the supplied matcher.- Parameters:
matcher
- The matcher that decides what methods or constructors the represented extension is applied to.- Returns:
- An appropriate ASM visitor wrapper.
-