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 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's RetentionPolicy annotation.
  • Field Details

  • Constructor Details

    • Explicit

      public Explicit(int parameterIndex, 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(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, 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 Details

    • 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 interface MethodAttributeAppender.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 interface MethodAttributeAppender
      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.