Class 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.
  • Constructor Details

    • 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 Details

    • annotateMethod

      public MemberAttributeExtension.ForMethod annotateMethod(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(List<? extends 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(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, 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, 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 interface AsmVisitorWrapper.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 ASM ClassWriter reader flags to consider.
      readerFlags - The ASM ClassReader reader 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.