Class MemberAttributeExtension.ForMethod

    • 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:
        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.