org.springframework.core.type.classreading

Class AnnotationMetadataReadingVisitor

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.String annotationName)
      Retrieve all attributes of all annotations of the given type, if any (i.e.
      MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.String annotationName, boolean classValuesAsString)
      Retrieve all attributes of all annotations of the given type, if any (i.e.
      java.util.Set<MethodMetadata> getAnnotatedMethods(java.lang.String annotationName)
      Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.
      AnnotationAttributes getAnnotationAttributes(java.lang.String annotationName)
      Retrieve the attributes of the annotation of the given type, if any (i.e.
      AnnotationAttributes getAnnotationAttributes(java.lang.String annotationName, boolean classValuesAsString)
      Retrieve the attributes of the annotation of the given type, if any (i.e.
      java.util.Set<java.lang.String> getAnnotationTypes()
      Get the fully qualified class names of all annotation types that are present on the underlying class.
      java.lang.String getClassName()
      Return the name of the underlying class.
      java.lang.String getEnclosingClassName()
      Return the name of the enclosing class of the underlying class, or null if the underlying class is a top-level class.
      java.lang.String[] getInterfaceNames()
      Return the names of all interfaces that the underlying class implements, or an empty array if there are none.
      java.lang.String[] getMemberClassNames()
      Return the names of all classes declared as members of the class represented by this ClassMetadata object.
      java.util.Set<java.lang.String> getMetaAnnotationTypes(java.lang.String annotationName)
      Get the fully qualified class names of all meta-annotation types that are present on the given annotation type on the underlying class.
      java.lang.String getSuperClassName()
      Return the name of the super class of the underlying class, or null if there is no super class defined.
      boolean hasAnnotatedMethods(java.lang.String annotationName)
      Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.
      boolean hasAnnotation(java.lang.String annotationName)
      Determine whether an annotation of the given type is present on the underlying class.
      boolean hasEnclosingClass()
      Return whether the underlying class is declared within an enclosing class (i.e.
      boolean hasMetaAnnotation(java.lang.String metaAnnotationType)
      Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.
      boolean hasSuperClass()
      Return whether the underlying class has a super class.
      boolean isAbstract()
      Return whether the underlying class is marked as abstract.
      boolean isAnnotated(java.lang.String annotationName)
      Determine whether the underlying element has an annotation or meta-annotation of the given type defined.
      boolean isAnnotation()
      Return whether the underlying class represents an annotation.
      boolean isConcrete()
      Return whether the underlying class represents a concrete class, i.e.
      boolean isFinal()
      Return whether the underlying class is marked as 'final'.
      boolean isIndependent()
      Determine whether the underlying class is independent, i.e.
      boolean isInterface()
      Return whether the underlying class represents an interface.
      void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String supername, java.lang.String[] interfaces)
      Visits the header of the class.
      AnnotationVisitor visitAnnotation(java.lang.String desc, boolean visible)
      Visits an annotation of the class.
      void visitAttribute(Attribute attr)
      Visits a non standard attribute of the class.
      void visitEnd()
      Visits the end of the class.
      FieldVisitor visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
      Visits a field of the class.
      void visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
      Visits information about an inner class.
      MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
      Visits a method of the class.
      void visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)
      Visits the enclosing class of the class.
      void visitSource(java.lang.String source, java.lang.String debug)
      Visits the source of the class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • classLoader

        @Nullable
        protected final java.lang.ClassLoader classLoader
      • annotationSet

        protected final java.util.Set<java.lang.String> annotationSet
      • metaAnnotationMap

        protected final java.util.Map<java.lang.String,java.util.Set<java.lang.String>> metaAnnotationMap
      • attributesMap

        protected final LinkedMultiValueMap<java.lang.String,AnnotationAttributes> attributesMap
        Declared as a LinkedMultiValueMap instead of a MultiValueMap to ensure that the hierarchical ordering of the entries is preserved.
        See Also:
        AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(org.springframework.util.LinkedMultiValueMap<java.lang.String, org.springframework.core.annotation.AnnotationAttributes>, java.util.Map<java.lang.String, java.util.Set<java.lang.String>>, java.lang.String)
      • methodMetadataSet

        protected final java.util.Set<MethodMetadata> methodMetadataSet
    • Constructor Detail

      • AnnotationMetadataReadingVisitor

        public AnnotationMetadataReadingVisitor(@Nullable
                                                java.lang.ClassLoader classLoader)
    • Method Detail

      • visitMethod

        public MethodVisitor visitMethod(int access,
                                         java.lang.String name,
                                         java.lang.String desc,
                                         java.lang.String signature,
                                         java.lang.String[] exceptions)
        Description copied from class: ClassVisitor
        Visits a method of the class. This method must return a new MethodVisitor instance (or null) each time it is called, i.e., it should not return a previously returned visitor.
        Parameters:
        access - the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
        name - the method's name.
        desc - the method's descriptor (see Type).
        signature - the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
        exceptions - the internal names of the method's exception classes (see Type.getInternalName()). May be null.
        Returns:
        an object to visit the byte code of the method, or null if this class visitor is not interested in visiting the code of this method.
      • visitAnnotation

        public AnnotationVisitor visitAnnotation(java.lang.String desc,
                                                 boolean visible)
        Description copied from class: ClassVisitor
        Visits an annotation of the class.
        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.
      • getAnnotationTypes

        public java.util.Set<java.lang.String> getAnnotationTypes()
        Description copied from interface: AnnotationMetadata
        Get the fully qualified class names of all annotation types that are present on the underlying class.
        Specified by:
        getAnnotationTypes in interface AnnotationMetadata
        Returns:
        the annotation type names
      • getMetaAnnotationTypes

        public java.util.Set<java.lang.String> getMetaAnnotationTypes(java.lang.String annotationName)
        Description copied from interface: AnnotationMetadata
        Get the fully qualified class names of all meta-annotation types that are present on the given annotation type on the underlying class.
        Specified by:
        getMetaAnnotationTypes in interface AnnotationMetadata
        Parameters:
        annotationName - the fully qualified class name of the meta-annotation type to look for
        Returns:
        the meta-annotation type names, or an empty set if none found
      • hasAnnotation

        public boolean hasAnnotation(java.lang.String annotationName)
        Description copied from interface: AnnotationMetadata
        Determine whether an annotation of the given type is present on the underlying class.
        Specified by:
        hasAnnotation in interface AnnotationMetadata
        Parameters:
        annotationName - the fully qualified class name of the annotation type to look for
        Returns:
        true if a matching annotation is present
      • hasMetaAnnotation

        public boolean hasMetaAnnotation(java.lang.String metaAnnotationType)
        Description copied from interface: AnnotationMetadata
        Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.
        Specified by:
        hasMetaAnnotation in interface AnnotationMetadata
        Parameters:
        metaAnnotationType - the fully qualified class name of the meta-annotation type to look for
        Returns:
        true if a matching meta-annotation is present
      • getAnnotationAttributes

        @Nullable
        public AnnotationAttributes getAnnotationAttributes(java.lang.String annotationName)
        Description copied from interface: AnnotatedTypeMetadata
        Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying element, as direct annotation or meta-annotation), also taking attribute overrides on composed annotations into account.
        Specified by:
        getAnnotationAttributes in interface AnnotatedTypeMetadata
        Parameters:
        annotationName - the fully qualified class name of 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

        @Nullable
        public AnnotationAttributes getAnnotationAttributes(java.lang.String annotationName,
                                                                      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 element, as direct annotation or meta-annotation), also taking attribute overrides on composed annotations into account.
        Specified by:
        getAnnotationAttributes in interface AnnotatedTypeMetadata
        Parameters:
        annotationName - the fully qualified class name of 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

        @Nullable
        public MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.String annotationName)
        Description copied from interface: AnnotatedTypeMetadata
        Retrieve all attributes of all annotations of the given type, if any (i.e. if defined on the underlying element, as direct annotation or meta-annotation). Note that this variant does not take attribute overrides into account.
        Specified by:
        getAllAnnotationAttributes in interface AnnotatedTypeMetadata
        Parameters:
        annotationName - the fully qualified class name of 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

        @Nullable
        public MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.String annotationName,
                                                                                                     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 element, as direct annotation or meta-annotation). Note that this variant does not take attribute overrides into account.
        Specified by:
        getAllAnnotationAttributes in interface AnnotatedTypeMetadata
        Parameters:
        annotationName - the fully qualified class name of 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)
      • hasAnnotatedMethods

        public boolean hasAnnotatedMethods(java.lang.String annotationName)
        Description copied from interface: AnnotationMetadata
        Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.
        Specified by:
        hasAnnotatedMethods in interface AnnotationMetadata
        Parameters:
        annotationName - the fully qualified class name of the annotation type to look for
      • getAnnotatedMethods

        public java.util.Set<MethodMetadata> getAnnotatedMethods(java.lang.String annotationName)
        Description copied from interface: AnnotationMetadata
        Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.

        For any returned method, AnnotatedTypeMetadata.isAnnotated(java.lang.String) will return true for the given annotation type.

        Specified by:
        getAnnotatedMethods in interface AnnotationMetadata
        Parameters:
        annotationName - the fully qualified class name of the annotation type to look for
        Returns:
        a set of MethodMetadata for methods that have a matching annotation. The return value will be an empty set if no methods match the annotation type.
      • visit

        public void visit(int version,
                          int access,
                          java.lang.String name,
                          java.lang.String signature,
                          @Nullable
                          java.lang.String supername,
                          java.lang.String[] interfaces)
        Description copied from class: ClassVisitor
        Visits the header of the class.
        Overrides:
        visit in class ClassVisitor
        Parameters:
        version - the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.
        access - the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated.
        name - the internal name of the class (see Type.getInternalName()).
        signature - the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
        supername - the internal of name of the super class (see Type.getInternalName()). For interfaces, the super class is Object. May be null, but only for the Object class.
        interfaces - the internal names of the class's interfaces (see Type.getInternalName()). May be null.
      • visitOuterClass

        public void visitOuterClass(java.lang.String owner,
                                    java.lang.String name,
                                    java.lang.String desc)
        Description copied from class: ClassVisitor
        Visits the enclosing class of the class. This method must be called only if the class has an enclosing class.
        Overrides:
        visitOuterClass in class ClassVisitor
        Parameters:
        owner - internal name of the enclosing class of the class.
        name - the name of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
        desc - the descriptor of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
      • visitInnerClass

        public void visitInnerClass(java.lang.String name,
                                    @Nullable
                                    java.lang.String outerName,
                                    java.lang.String innerName,
                                    int access)
        Description copied from class: ClassVisitor
        Visits information about an inner class. This inner class is not necessarily a member of the class being visited.
        Overrides:
        visitInnerClass in class ClassVisitor
        Parameters:
        name - the internal name of an inner class (see Type.getInternalName()).
        outerName - the internal name of the class to which the inner class belongs (see Type.getInternalName()). May be null for not member classes.
        innerName - the (simple) name of the inner class inside its enclosing class. May be null for anonymous inner classes.
        access - the access flags of the inner class as originally declared in the enclosing class.
      • visitSource

        public void visitSource(java.lang.String source,
                                java.lang.String debug)
        Description copied from class: ClassVisitor
        Visits the source of the class.
        Overrides:
        visitSource in class ClassVisitor
        Parameters:
        source - the name of the source file from which the class was compiled. May be null.
        debug - additional debug information to compute the correspondence between source and compiled elements of the class. May be null.
      • visitAttribute

        public void visitAttribute(Attribute attr)
        Description copied from class: ClassVisitor
        Visits a non standard attribute of the class.
        Overrides:
        visitAttribute in class ClassVisitor
        Parameters:
        attr - an attribute.
      • visitField

        public FieldVisitor visitField(int access,
                                       java.lang.String name,
                                       java.lang.String desc,
                                       java.lang.String signature,
                                       java.lang.Object value)
        Description copied from class: ClassVisitor
        Visits a field of the class.
        Overrides:
        visitField in class ClassVisitor
        Parameters:
        access - the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.
        name - the field's name.
        desc - the field's descriptor (see Type).
        signature - the field's signature. May be null if the field's type does not use generic types.
        value - the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.
        Returns:
        a visitor to visit field annotations and attributes, or null if this class visitor is not interested in visiting these annotations and attributes.
      • visitEnd

        public void visitEnd()
        Description copied from class: ClassVisitor
        Visits the end of the class. This method, which is the last one to be called, is used to inform the visitor that all the fields and methods of the class have been visited.
        Overrides:
        visitEnd in class ClassVisitor
      • getClassName

        public java.lang.String getClassName()
        Description copied from interface: ClassMetadata
        Return the name of the underlying class.
        Specified by:
        getClassName in interface ClassMetadata
      • isInterface

        public boolean isInterface()
        Description copied from interface: ClassMetadata
        Return whether the underlying class represents an interface.
        Specified by:
        isInterface in interface ClassMetadata
      • isAnnotation

        public boolean isAnnotation()
        Description copied from interface: ClassMetadata
        Return whether the underlying class represents an annotation.
        Specified by:
        isAnnotation in interface ClassMetadata
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: ClassMetadata
        Return whether the underlying class is marked as abstract.
        Specified by:
        isAbstract in interface ClassMetadata
      • isConcrete

        public boolean isConcrete()
        Description copied from interface: ClassMetadata
        Return whether the underlying class represents a concrete class, i.e. neither an interface nor an abstract class.
        Specified by:
        isConcrete in interface ClassMetadata
      • isFinal

        public boolean isFinal()
        Description copied from interface: ClassMetadata
        Return whether the underlying class is marked as 'final'.
        Specified by:
        isFinal in interface ClassMetadata
      • isIndependent

        public boolean isIndependent()
        Description copied from interface: ClassMetadata
        Determine whether the underlying class is independent, i.e. whether it is a top-level class or a nested class (static inner class) that can be constructed independently from an enclosing class.
        Specified by:
        isIndependent in interface ClassMetadata
      • hasEnclosingClass

        public boolean hasEnclosingClass()
        Description copied from interface: ClassMetadata
        Return whether the underlying class is declared within an enclosing class (i.e. the underlying class is an inner/nested class or a local class within a method).

        If this method returns false, then the underlying class is a top-level class.

        Specified by:
        hasEnclosingClass in interface ClassMetadata
      • getEnclosingClassName

        @Nullable
        public java.lang.String getEnclosingClassName()
        Description copied from interface: ClassMetadata
        Return the name of the enclosing class of the underlying class, or null if the underlying class is a top-level class.
        Specified by:
        getEnclosingClassName in interface ClassMetadata
      • hasSuperClass

        public boolean hasSuperClass()
        Description copied from interface: ClassMetadata
        Return whether the underlying class has a super class.
        Specified by:
        hasSuperClass in interface ClassMetadata
      • getSuperClassName

        @Nullable
        public java.lang.String getSuperClassName()
        Description copied from interface: ClassMetadata
        Return the name of the super class of the underlying class, or null if there is no super class defined.
        Specified by:
        getSuperClassName in interface ClassMetadata
      • getInterfaceNames

        public java.lang.String[] getInterfaceNames()
        Description copied from interface: ClassMetadata
        Return the names of all interfaces that the underlying class implements, or an empty array if there are none.
        Specified by:
        getInterfaceNames in interface ClassMetadata
      • getMemberClassNames

        public java.lang.String[] getMemberClassNames()
        Description copied from interface: ClassMetadata
        Return the names of all classes declared as members of the class represented by this ClassMetadata object. This includes public, protected, default (package) access, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces. An empty array is returned if no member classes or interfaces exist.
        Specified by:
        getMemberClassNames in interface ClassMetadata