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 Classes Modifier and Type Class Description private static classMemberAttributeExtension.ForMethod.AttributeAppendingMethodVisitorA 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
Constructors Modifier Constructor Description ForMethod()Creates a method attribute extension.ForMethod(AnnotationValueFilter.Factory annotationValueFilterFactory)Creates a method attribute extension.protectedForMethod(AnnotationValueFilter.Factory annotationValueFilterFactory, MethodAttributeAppender.Factory attributeAppenderFactory)Creates a method attribute extension.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MemberAttributeExtension.ForMethodannotateMethod(java.lang.annotation.Annotation... annotation)Appends the supplied annotations.MemberAttributeExtension.ForMethodannotateMethod(java.util.Collection<? extends AnnotationDescription> annotations)Appends the supplied annotations.MemberAttributeExtension.ForMethodannotateMethod(java.util.List<? extends java.lang.annotation.Annotation> annotations)Appends the supplied annotations.MemberAttributeExtension.ForMethodannotateMethod(AnnotationDescription... annotation)Appends the supplied annotations.MemberAttributeExtension.ForMethodannotateParameter(int index, java.lang.annotation.Annotation... annotation)Appends the supplied annotations to the parameter at the given index.MemberAttributeExtension.ForMethodannotateParameter(int index, java.util.Collection<? extends AnnotationDescription> annotations)Appends the supplied annotations to the parameter at the given index.MemberAttributeExtension.ForMethodannotateParameter(int index, java.util.List<? extends java.lang.annotation.Annotation> annotations)Appends the supplied annotations to the parameter at the given index.MemberAttributeExtension.ForMethodannotateParameter(int index, AnnotationDescription... annotation)Appends the supplied annotations to the parameter at the given index.MemberAttributeExtension.ForMethodattribute(MethodAttributeAppender.Factory attributeAppenderFactory)Appends the supplied method attribute appender factory.AsmVisitorWrapperon(ElementMatcher<? super MethodDescription> matcher)Applies this attribute extension on any method or constructor that matches the supplied matcher.org.objectweb.asm.MethodVisitorwrap(TypeDescription instrumentedType, MethodDescription instrumentedMethod, org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, TypePool typePool, int writerFlags, int readerFlags)Wraps a method visitor.
-
-
-
Constructor Detail
-
ForMethod
public ForMethod()
Creates a method attribute extension.
-
ForMethod
public ForMethod(AnnotationValueFilter.Factory annotationValueFilterFactory)
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 Detail
-
annotateMethod
public MemberAttributeExtension.ForMethod annotateMethod(java.lang.annotation.Annotation... annotation)
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(java.util.List<? extends java.lang.annotation.Annotation> 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.
-
annotateMethod
public MemberAttributeExtension.ForMethod annotateMethod(AnnotationDescription... annotation)
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(java.util.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
public MemberAttributeExtension.ForMethod annotateParameter(int index, java.lang.annotation.Annotation... 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, java.util.List<? extends java.lang.annotation.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, java.util.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:
wrapin 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 ASMClassWriterreader flags to consider.readerFlags- The ASMClassReaderreader flags to consider.- Returns:
- The wrapped method visitor.
-
on
public AsmVisitorWrapper on(ElementMatcher<? super MethodDescription> matcher)
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.
-
-