类 AnnotationAttributes

    • 方法详细资料

      • annotationType

        public Class<? extends AnnotationannotationType()
        Get the type of annotation represented by this AnnotationAttributes instance.
        返回:
        the annotation type, or null if unknown
        从以下版本开始:
        4.2
      • getString

        public String getString​(String attributeName)
        Get the value stored under the specified attributeName as a string.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAliasedString

        @Deprecated
        public String getAliasedString​(String attributeName,
                                       Class<? extends Annotation> annotationType,
                                       Object annotationSource)
        已过时。
        as of Spring 4.3.2, in favor of built-in alias resolution in getString(java.lang.String) itself
        Get the value stored under the specified attributeName as a string, taking into account alias semantics defined via @AliasFor.

        If there is no value stored under the specified attributeName but the attribute has an alias declared via @AliasFor, the value of the alias will be returned.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the type of annotation represented by this AnnotationAttributes instance; never null
        annotationSource - the source of the annotation represented by this AnnotationAttributes (e.g., the AnnotatedElement); or null if unknown
        返回:
        the string value
        抛出:
        IllegalArgumentException - if the attribute and its alias do not exist or are not of type String
        AnnotationConfigurationException - if the attribute and its alias are both present with different non-empty values
        从以下版本开始:
        4.2
      • getStringArray

        public String[] getStringArray​(String attributeName)
        Get the value stored under the specified attributeName as an array of strings.

        If the value stored under the specified attributeName is a string, it will be wrapped in a single-element array before returning it.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAliasedStringArray

        @Deprecated
        public String[] getAliasedStringArray​(String attributeName,
                                              Class<? extends Annotation> annotationType,
                                              Object annotationSource)
        已过时。
        as of Spring 4.3.2, in favor of built-in alias resolution in getStringArray(java.lang.String) itself
        Get the value stored under the specified attributeName as an array of strings, taking into account alias semantics defined via @AliasFor.

        If there is no value stored under the specified attributeName but the attribute has an alias declared via @AliasFor, the value of the alias will be returned.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the type of annotation represented by this AnnotationAttributes instance; never null
        annotationSource - the source of the annotation represented by this AnnotationAttributes (e.g., the AnnotatedElement); or null if unknown
        返回:
        the array of strings
        抛出:
        IllegalArgumentException - if the attribute and its alias do not exist or are not of type String[]
        AnnotationConfigurationException - if the attribute and its alias are both present with different non-empty values
        从以下版本开始:
        4.2
      • getBoolean

        public boolean getBoolean​(String attributeName)
        Get the value stored under the specified attributeName as a boolean.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getNumber

        public <N extends Number> N getNumber​(String attributeName)
        Get the value stored under the specified attributeName as a number.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getEnum

        public <E extends Enum<?>> E getEnum​(String attributeName)
        Get the value stored under the specified attributeName as an enum.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getClass

        public <T> Class<? extends T> getClass​(String attributeName)
        Get the value stored under the specified attributeName as a class.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getClassArray

        public Class<?>[] getClassArray​(String attributeName)
        Get the value stored under the specified attributeName as an array of classes.

        If the value stored under the specified attributeName is a class, it will be wrapped in a single-element array before returning it.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the value
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAliasedClassArray

        @Deprecated
        public Class<?>[] getAliasedClassArray​(String attributeName,
                                               Class<? extends Annotation> annotationType,
                                               Object annotationSource)
        已过时。
        as of Spring 4.3.2, in favor of built-in alias resolution in getClassArray(java.lang.String) itself
        Get the value stored under the specified attributeName as an array of classes, taking into account alias semantics defined via @AliasFor.

        If there is no value stored under the specified attributeName but the attribute has an alias declared via @AliasFor, the value of the alias will be returned.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the type of annotation represented by this AnnotationAttributes instance; never null
        annotationSource - the source of the annotation represented by this AnnotationAttributes (e.g., the AnnotatedElement); or null if unknown
        返回:
        the array of classes
        抛出:
        IllegalArgumentException - if the attribute and its alias do not exist or are not of type Class[]
        AnnotationConfigurationException - if the attribute and its alias are both present with different non-empty values
        从以下版本开始:
        4.2
      • getAnnotation

        public <A extends Annotation> A getAnnotation​(String attributeName,
                                                      Class<A> annotationType)
        Get the annotation of type annotationType stored under the specified attributeName.
        参数:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the expected annotation type; never null
        返回:
        the annotation
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
        从以下版本开始:
        4.2
      • getAnnotationArray

        public AnnotationAttributes[] getAnnotationArray​(String attributeName)
        Get the array of AnnotationAttributes stored under the specified attributeName.

        If the value stored under the specified attributeName is an instance of AnnotationAttributes, it will be wrapped in a single-element array before returning it.

        Note: if you expect an actual array of annotations, invoke getAnnotationArray(String, Class) instead.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        返回:
        the array of AnnotationAttributes
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAnnotationArray

        public <A extends Annotation> A[] getAnnotationArray​(String attributeName,
                                                             Class<A> annotationType)
        Get the array of type annotationType stored under the specified attributeName.

        If the value stored under the specified attributeName is an Annotation, it will be wrapped in a single-element array before returning it.

        参数:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the expected annotation type; never null
        返回:
        the annotation array
        抛出:
        IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
        从以下版本开始:
        4.2
      • fromMap

        public static AnnotationAttributes fromMap​(Map<String,​Object> map)
        Return an AnnotationAttributes instance based on the given map.

        If the map is already an AnnotationAttributes instance, it will be cast and returned immediately without creating a new instance. Otherwise a new instance will be created by passing the supplied map to the AnnotationAttributes(Map) constructor.

        参数:
        map - original source of annotation attribute key-value pairs