org.springframework.core.type.classreading

## Class MethodMetadataReadingVisitor

- java.lang.Object
- - org.springframework.asm.MethodVisitor
  - - org.springframework.core.type.classreading.MethodMetadataReadingVisitor

- All Implemented Interfaces:
    AnnotatedTypeMetadata, MethodMetadata

      public class MethodMetadataReadingVisitor
      extends MethodVisitor
      implements MethodMetadata

  ASM method visitor which looks for the annotations defined on the method, exposing them through the `MethodMetadata` interface.
  Since:
    3.0
  Author:
    Juergen Hoeller, Mark Pollack, Costin Leau, Chris Beams, Phillip Webb

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `access`
    `protected MultiValueMap<String,AnnotationAttributes>` | `attributeMap`
    `protected ClassLoader` | `classLoader`
    `protected String` | `declaringClassName`
    `protected Set<MethodMetadata>` | `methodMetadataSet`
    `protected String` | `name`

    - ### Fields inherited from class org.springframework.asm.MethodVisitor

      `api, mv`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MethodMetadataReadingVisitor(String name, int access, String declaringClassName, ClassLoader classLoader, Set<MethodMetadata> methodMetadataSet)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MultiValueMap<String,Object>` | `getAllAnnotationAttributes(String annotationType)` Retrieve all attributes of all annotations of the given type, if any (i.e.
    `MultiValueMap<String,Object>` | `getAllAnnotationAttributes(String annotationType, boolean classValuesAsString)` Retrieve all attributes of all annotations of the given type, if any (i.e.
    `Map<String,Object>` | `getAnnotationAttributes(String annotationType)` Retrieve the attributes of the annotation of the given type, if any (i.e.
    `Map<String,Object>` | `getAnnotationAttributes(String annotationType, boolean classValuesAsString)` Retrieve the attributes of the annotation of the given type, if any (i.e.
    `String` | `getDeclaringClassName()` Return the fully-qualified name of the class that declares this method.
    `String` | `getMethodName()` Return the name of the method.
    `boolean` | `isAnnotated(String annotationType)` Determine whether the underlying type has an annotation or meta-annotation of the given type defined.
    `boolean` | `isFinal()` Return whether the underlying method is marked as 'final'.
    `boolean` | `isOverridable()` Return whether the underlying method is overridable, i.e.
    `boolean` | `isStatic()` Return whether the underlying method is declared as 'static'.
    `AnnotationVisitor` | `visitAnnotation(String desc, boolean visible)` Visits an annotation of this method.

    - ### Methods inherited from class org.springframework.asm.MethodVisitor

      `visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitFrame, visitIincInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn, visitVarInsn`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### name

          protected final String name

    - #### access

          protected final int access

    - #### declaringClassName

          protected final String declaringClassName

    - #### classLoader

          protected final ClassLoader classLoader

    - #### methodMetadataSet

          protected final Set<MethodMetadata> methodMetadataSet

    - #### attributeMap

          protected final MultiValueMap<String,AnnotationAttributes> attributeMap

  - ### Constructor Detail

    - #### MethodMetadataReadingVisitor

          public MethodMetadataReadingVisitor(String name,
                                              int access,
                                              String declaringClassName,
                                              ClassLoader classLoader,
                                              Set<MethodMetadata> methodMetadataSet)

  - ### Method Detail

    - #### visitAnnotation

          public AnnotationVisitor visitAnnotation(String desc,
                                                   boolean visible)

      Description copied from class: `MethodVisitor`
      Visits an annotation of this method.
      Overrides:
        `visitAnnotation` in class `MethodVisitor`
      Parameters:
        `desc` - the class descriptor of the annotation class.
        `visible` - `true` if the annotation is visible at runtime.
      Returns:
        a visitor to visit the annotation values, or `null` if this visitor is not interested in visiting this annotation.

    - #### getMethodName

          public String getMethodName()

      Description copied from interface: `MethodMetadata`
      Return the name of the method.
      Specified by:
        `getMethodName` in interface `MethodMetadata`

    - #### isStatic

          public boolean isStatic()

      Description copied from interface: `MethodMetadata`
      Return whether the underlying method is declared as 'static'.
      Specified by:
        `isStatic` in interface `MethodMetadata`

    - #### isFinal

          public boolean isFinal()

      Description copied from interface: `MethodMetadata`
      Return whether the underlying method is marked as 'final'.
      Specified by:
        `isFinal` in interface `MethodMetadata`

    - #### isOverridable

          public boolean isOverridable()

      Description copied from interface: `MethodMetadata`
      Return whether the underlying method is overridable, i.e. not marked as static, final or private.
      Specified by:
        `isOverridable` in interface `MethodMetadata`

    - #### isAnnotated

          public boolean isAnnotated(String annotationType)

      Description copied from interface: `AnnotatedTypeMetadata`
      Determine whether the underlying type has an annotation or meta-annotation of the given type defined.

      If this method returns `true`, then `AnnotatedTypeMetadata.getAnnotationAttributes(java.lang.String)` will return a non-null Map.

      Specified by:
        `isAnnotated` in interface `AnnotatedTypeMetadata`
      Parameters:
        `annotationType` - the annotation type to look for
      Returns:
        whether a matching annotation is defined

    - #### getAnnotationAttributes

          public Map<String,Object> getAnnotationAttributes(String annotationType)

      Description copied from interface: `AnnotatedTypeMetadata`
      Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class, as direct annotation or as meta-annotation).
      Specified by:
        `getAnnotationAttributes` in interface `AnnotatedTypeMetadata`
      Parameters:
        `annotationType` - the annotation type to look for
      Returns:
        a Map of attributes, with the attribute name as key (e.g. "value") and the defined attribute value as Map value. This return value will be `null` if no matching annotation is defined.

    - #### getAnnotationAttributes

          public Map<String,Object> getAnnotationAttributes(String annotationType,
                                                            boolean classValuesAsString)

      Description copied from interface: `AnnotatedTypeMetadata`
      Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class, as direct annotation or as meta-annotation).
      Specified by:
        `getAnnotationAttributes` in interface `AnnotatedTypeMetadata`
      Parameters:
        `annotationType` - the annotation type to look for
        `classValuesAsString` - whether to convert class references to String class names for exposure as values in the returned Map, instead of Class references which might potentially have to be loaded first
      Returns:
        a Map of attributes, with the attribute name as key (e.g. "value") and the defined attribute value as Map value. This return value will be `null` if no matching annotation is defined.

    - #### getAllAnnotationAttributes

          public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationType)

      Description copied from interface: `AnnotatedTypeMetadata`
      Retrieve all attributes of all annotations of the given type, if any (i.e. if defined on the underlying type (`class` or `method`), as direct annotation or as meta-annotation).
      Specified by:
        `getAllAnnotationAttributes` in interface `AnnotatedTypeMetadata`
      Parameters:
        `annotationType` - the annotation type to look for
      Returns:
        a MultiMap of attributes, with the attribute name as key (e.g. "value") and a list of the defined attribute values as Map value. This return value will be `null` if no matching annotation is defined.
      See Also:
        `AnnotatedTypeMetadata.getAllAnnotationAttributes(String, boolean)`

    - #### getAllAnnotationAttributes

          public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationType,
                                                                         boolean classValuesAsString)

      Description copied from interface: `AnnotatedTypeMetadata`
      Retrieve all attributes of all annotations of the given type, if any (i.e. if defined on the underlying type (`class` or `method`), as direct annotation or as meta-annotation).
      Specified by:
        `getAllAnnotationAttributes` in interface `AnnotatedTypeMetadata`
      Parameters:
        `annotationType` - the annotation type to look for
        `classValuesAsString` - whether to convert class references to String
      Returns:
        a MultiMap of attributes, with the attribute name as key (e.g. "value") and a list of the defined attribute values as Map value. This return value will be `null` if no matching annotation is defined.
      See Also:
        `AnnotatedTypeMetadata.getAllAnnotationAttributes(String)`

    - #### getDeclaringClassName

          public String getDeclaringClassName()

      Description copied from interface: `MethodMetadata`
      Return the fully-qualified name of the class that declares this method.
      Specified by:
        `getDeclaringClassName` in interface `MethodMetadata`