Class AnnotationUtils


  • public abstract class AnnotationUtils
    extends java.lang.Object
    Annotation Utilities
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Annotation
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnotationUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A extends java.lang.annotation.Annotation>
      java.util.Map<java.lang.annotation.ElementType,​java.util.List<A>>
      findAnnotations​(java.lang.reflect.Method method, java.lang.Class<A> annotationClass)
      Find specified Annotation type maps from Method
      static <A extends java.lang.annotation.Annotation>
      java.lang.Class<A>
      findAnnotationType​(org.springframework.core.annotation.AnnotationAttributes annotationAttributes)
      Find the class of Annotation from the specified AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, boolean tryMergedAnnotation, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from merged annotation first, if failed, and then to get from normal one
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, boolean tryMergedAnnotation, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from merged annotation first, if failed, and then to get from normal one
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the AnnotationAttributes
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(org.springframework.core.type.AnnotationMetadata metadata, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of annotation.
      static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(org.springframework.core.type.AnnotationMetadata metadata, java.lang.String annotationClassName)
      Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of annotation.
      static <T> T getAttribute​(java.lang.annotation.Annotation annotation, java.lang.String attributeName)
      Get the attribute value
      static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes, java.lang.String attributeName)
      Get the attribute value
      static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes, java.lang.String attributeName, boolean required)
      Get the attribute value the will
      static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes, java.lang.String attributeName, T defaultValue)
      Get the attribute value with default value
      static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the Annotation attributes
      static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)  
      static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Get the Annotation attributes
      static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.util.Map<java.lang.String,​java.lang.Object> annotationAttributes, org.springframework.core.env.PropertyResolver propertyResolver, java.lang.String... ignoreAttributeNames)
      Get the Annotation attributes
      static <T> T getRequiredAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes, java.lang.String attributeName)
      Get the required attribute value
      static <A extends java.lang.annotation.Annotation>
      boolean
      isPresent​(java.lang.reflect.Method method, java.lang.Class<A> annotationClass)
      Is specified Annotation present on Method's declaring class or parameters or itself.
      static java.lang.annotation.Annotation tryGetMergedAnnotation​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Try to get the merged annotation
      static java.lang.annotation.Annotation tryGetMergedAnnotation​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
      Try to get the merged annotation
      static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Try to get the annotation attributes after merging and resolving the placeholders
      static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, java.lang.String... ignoreAttributeNames)
      Try to get the annotation attributes after merging and resolving the placeholders
      • Methods inherited from class java.lang.Object

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

      • ANNOTATED_ELEMENT_UTILS_CLASS_NAME

        public static final java.lang.String ANNOTATED_ELEMENT_UTILS_CLASS_NAME
        The class name of that is introduced since Spring Framework 4
        See Also:
        Constant Field Values
      • ANNOTATED_ELEMENT_UTILS_CLASS

        public static final java.lang.Class<?> ANNOTATED_ELEMENT_UTILS_CLASS
        The Class of AnnotatedElementUtils that is introduced since Spring Framework 4
      • ANNOTATION_ATTRIBUTES_ANNOTATION_TYPE_METHOD

        public static final java.lang.reflect.Method ANNOTATION_ATTRIBUTES_ANNOTATION_TYPE_METHOD
        The Method object of AnnotationAttributes.annotationType() is introduced since Spring Framework 4.2
    • Constructor Detail

      • AnnotationUtils

        public AnnotationUtils()
    • Method Detail

      • isPresent

        public static <A extends java.lang.annotation.Annotation> boolean isPresent​(java.lang.reflect.Method method,
                                                                                    java.lang.Class<A> annotationClass)
        Is specified Annotation present on Method's declaring class or parameters or itself.
        Type Parameters:
        A - Annotation type
        Parameters:
        method - Method
        annotationClass - Annotation type
        Returns:
        If present , return true , or false
      • findAnnotations

        public static <A extends java.lang.annotation.Annotation> java.util.Map<java.lang.annotation.ElementType,​java.util.List<A>> findAnnotations​(java.lang.reflect.Method method,
                                                                                                                                                          java.lang.Class<A> annotationClass)
        Find specified Annotation type maps from Method
        Type Parameters:
        A - Annotation type
        Parameters:
        method - Method
        annotationClass - Annotation type
        Returns:
        Annotation type maps , the ElementType as key , the list of Annotation as value. If Annotation was annotated on Method's parametersElementType.PARAMETER , the associated Annotation list may contain multiple elements.
      • getAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation,
                                                                                           boolean ignoreDefaultValue,
                                                                                           java.lang.String... ignoreAttributeNames)
        Get the Annotation attributes
        Parameters:
        annotation - specified Annotation
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        non-null
      • getAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation,
                                                                                           org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                           boolean ignoreDefaultValue,
                                                                                           java.lang.String... ignoreAttributeNames)
        Get the Annotation attributes
        Parameters:
        annotation - specified Annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        non-null
      • getAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.util.Map<java.lang.String,​java.lang.Object> annotationAttributes,
                                                                                           org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                           java.lang.String... ignoreAttributeNames)
        Get the Annotation attributes
        Parameters:
        annotationAttributes - the attributes of specified Annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        non-null
      • getAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getAttributes​(java.lang.annotation.Annotation annotation,
                                                                                           org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                           boolean classValuesAsString,
                                                                                           boolean nestedAnnotationsAsMap,
                                                                                           boolean ignoreDefaultValue,
                                                                                           java.lang.String... ignoreAttributeNames)
        Parameters:
        annotation - specified Annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        classValuesAsString - whether to turn Class references into Strings (for compatibility with AnnotationMetadata or to preserve them as Class references
        nestedAnnotationsAsMap - whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility with AnnotationMetadata or to preserve them as Annotation instances
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
      • getAttribute

        public static <T> T getAttribute​(java.lang.annotation.Annotation annotation,
                                         java.lang.String attributeName)
        Get the attribute value
        Type Parameters:
        T - the type of attribute value
        Parameters:
        annotation - annotation
        attributeName - the name of attribute
        Returns:
        the attribute value if found
      • getAttribute

        public static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                         java.lang.String attributeName)
        Get the attribute value
        Type Parameters:
        T - the type of attribute value
        Parameters:
        attributes - the annotation attributes or AnnotationAttributes
        attributeName - the name of attribute
        Returns:
        the attribute value if found
      • getAttribute

        public static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                         java.lang.String attributeName,
                                         boolean required)
        Get the attribute value the will
        Type Parameters:
        T - the type of attribute value
        Parameters:
        attributes - the annotation attributes or AnnotationAttributes
        attributeName - the name of attribute
        required - the required attribute or not
        Returns:
        the attribute value if found
        Throws:
        java.lang.IllegalStateException - if attribute value can't be found
      • getAttribute

        public static <T> T getAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                         java.lang.String attributeName,
                                         T defaultValue)
        Get the attribute value with default value
        Type Parameters:
        T - the type of attribute value
        Parameters:
        attributes - the annotation attributes or AnnotationAttributes
        attributeName - the name of attribute
        defaultValue - the default value of attribute
        Returns:
        the attribute value if found
      • getRequiredAttribute

        public static <T> T getRequiredAttribute​(java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                                 java.lang.String attributeName)
        Get the required attribute value
        Type Parameters:
        T - the type of attribute value
        Parameters:
        attributes - the annotation attributes or AnnotationAttributes
        attributeName - the name of attribute
        Returns:
        the attribute value if found
        Throws:
        java.lang.IllegalStateException - if attribute value can't be found
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes
        Parameters:
        annotation - specified Annotation
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        non-null
        See Also:
        getAnnotationAttributes(Annotation, PropertyResolver, boolean, String...)
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean classValuesAsString,
                                                                                                       boolean nestedAnnotationsAsMap,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes
        Parameters:
        annotation - specified Annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        classValuesAsString - whether to turn Class references into Strings (for compatibility with AnnotationMetadata or to preserve them as Class references
        nestedAnnotationsAsMap - whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility with AnnotationMetadata or to preserve them as Annotation instances
        ignoreAttributeNames - the attribute names of annotation should be ignored
        ignoreDefaultValue - whether ignore default value or not
        Returns:
        non-null
        See Also:
        getAttributes(Annotation, PropertyResolver, boolean, String...), getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...)
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.annotation.Annotation annotation,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes
        Parameters:
        annotation - specified Annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        non-null
        See Also:
        getAttributes(Annotation, PropertyResolver, boolean, String...), getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...)
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        if annotatedElement can't be found in annotatedElement, return null
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean classValuesAsString,
                                                                                                       boolean nestedAnnotationsAsMap,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        if annotatedElement can't be found in annotatedElement, return null
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       boolean tryMergedAnnotation,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from merged annotation first, if failed, and then to get from normal one
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        tryMergedAnnotation - whether try merged annotation or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        if annotatedElement can't be found in annotatedElement, return null
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                       org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                       boolean classValuesAsString,
                                                                                                       boolean nestedAnnotationsAsMap,
                                                                                                       boolean ignoreDefaultValue,
                                                                                                       boolean tryMergedAnnotation,
                                                                                                       java.lang.String... ignoreAttributeNames)
        Get the AnnotationAttributes, if the argument tryMergedAnnotation is true, the AnnotationAttributes will be got from merged annotation first, if failed, and then to get from normal one
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        classValuesAsString - whether to turn Class references into Strings (for compatibility with AnnotationMetadata or to preserve them as Class references
        nestedAnnotationsAsMap - whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility with AnnotationMetadata or to preserve them as Annotation instances
        ignoreDefaultValue - whether ignore default value or not
        tryMergedAnnotation - whether try merged annotation or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        if annotatedElement can't be found in annotatedElement, return null
      • tryGetMergedAnnotation

        public static java.lang.annotation.Annotation tryGetMergedAnnotation​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                             java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Try to get the merged annotation
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        Returns:
        If current version of Spring Framework is below 4.2, return null
      • tryGetMergedAnnotation

        public static java.lang.annotation.Annotation tryGetMergedAnnotation​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                             java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                             boolean classValuesAsString,
                                                                             boolean nestedAnnotationsAsMap)
        Try to get the merged annotation
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        classValuesAsString - whether to turn Class references into Strings (for compatibility with AnnotationMetadata or to preserve them as Class references
        nestedAnnotationsAsMap - whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility with AnnotationMetadata or to preserve them as Annotation instances
        Returns:
        If current version of Spring Framework is below 4.2, return null
      • tryGetMergedAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                                java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                                org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                                boolean ignoreDefaultValue,
                                                                                                                java.lang.String... ignoreAttributeNames)
        Try to get the annotation attributes after merging and resolving the placeholders
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        If the specified annotation type is not found, return null
      • tryGetMergedAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes​(java.lang.reflect.AnnotatedElement annotatedElement,
                                                                                                                java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                                                                                                org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                                                boolean classValuesAsString,
                                                                                                                boolean nestedAnnotationsAsMap,
                                                                                                                boolean ignoreDefaultValue,
                                                                                                                java.lang.String... ignoreAttributeNames)
        Try to get the annotation attributes after merging and resolving the placeholders
        Parameters:
        annotatedElement - the annotated element
        annotationType - the tyoe pf annotation
        propertyResolver - PropertyResolver instance, e.g Environment
        classValuesAsString - whether to turn Class references into Strings (for compatibility with AnnotationMetadata or to preserve them as Class references
        nestedAnnotationsAsMap - whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility with AnnotationMetadata or to preserve them as Annotation instances
        ignoreDefaultValue - whether ignore default value or not
        ignoreAttributeNames - the attribute names of annotation should be ignored
        Returns:
        If the specified annotation type is not found, return null
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(org.springframework.core.type.AnnotationMetadata metadata,
                                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of annotation.
        Parameters:
        metadata - AnnotationMetadata
        annotationType - The class of annotation
        Returns:
        non-null
      • getAnnotationAttributes

        public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes​(org.springframework.core.type.AnnotationMetadata metadata,
                                                                                                       java.lang.String annotationClassName)
        Get an instance of AnnotationAttributes from AnnotationMetadata with the specified class name of annotation.
        Parameters:
        metadata - AnnotationMetadata
        annotationClassName - The class name of annotation
        Returns:
        non-null
      • findAnnotationType

        @Nullable
        public static <A extends java.lang.annotation.Annotation> java.lang.Class<A> findAnnotationType​(org.springframework.core.annotation.AnnotationAttributes annotationAttributes)
        Find the class of Annotation from the specified AnnotationAttributes
        Type Parameters:
        A - The class of Annotation
        Parameters:
        annotationAttributes - AnnotationAttributes
        Returns:
        null if not found