类 AnnotationAttributes
- 所有已实现的接口:
Serializable,Cloneable,Map<String,Object>
LinkedHashMap subclass representing annotation attribute
key-value pairs as read by AnnotationUtils,
AnnotatedElementUtils, and reflection- and ASM-based
AnnotationMetadata implementations.
Provides 'pseudo-reification' to avoid noisy Map generics in the calling code as well as convenience methods for looking up annotation attributes in a type-safe fashion.
- 从以下版本开始:
- 4.0
- 作者:
- Chris Beams, Sam Brannen, Juergen Hoeller
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
字段概要
字段 -
构造器概要
构造器构造器说明Create a new, emptyAnnotationAttributesinstance.AnnotationAttributes(int initialCapacity) Create a new, emptyAnnotationAttributesinstance with the given initial capacity to optimize performance.Create a newAnnotationAttributesinstance, wrapping the provided map and all its key-value pairs.AnnotationAttributes(Class<? extends Annotation> annotationType) Create a new, emptyAnnotationAttributesinstance for the specifiedannotationType.AnnotationAttributes(String annotationType, ClassLoader classLoader) Create a new, emptyAnnotationAttributesinstance for the specifiedannotationType.AnnotationAttributes(Map<String, Object> map) Create a newAnnotationAttributesinstance, wrapping the provided map and all its key-value pairs. -
方法概要
修饰符和类型方法说明Class<? extends Annotation>Get the type of annotation represented by thisAnnotationAttributes.static AnnotationAttributesReturn anAnnotationAttributesinstance based on the given map.static AnnotationAttributesfromMetadata(AnnotatedTypeMetadata metadata, Class<?> annotationClass) static AnnotationAttributesfromMetadata(AnnotatedTypeMetadata metadata, String annotationClassName) getAnnotation(String attributeName) Get theAnnotationAttributesstored under the specifiedattributeName.<A extends Annotation>
AgetAnnotation(String attributeName, Class<A> annotationType) Get the annotation of typeannotationTypestored under the specifiedattributeName.getAnnotationArray(String attributeName) Get the array ofAnnotationAttributesstored under the specifiedattributeName.<A extends Annotation>
A[]getAnnotationArray(String attributeName, Class<A> annotationType) Get the array of typeannotationTypestored under the specifiedattributeName.booleangetBoolean(String attributeName) Get the value stored under the specifiedattributeNameas a boolean.<T> Class<? extends T>Get the value stored under the specifiedattributeNameas a class.<T> Class<T>[]getClassArray(String attributeName) Get the value stored under the specifiedattributeNameas an array of classes.<E extends Enum<?>>
EGet the value stored under the specifiedattributeNameas an enum.<N extends Number>
NGet the value stored under the specifiedattributeNameas a number.<T> TgetRequiredAttribute(String attributeName, Class<T> expectedType) Get the value stored under the specifiedattributeName, ensuring that the value is of theexpectedType.Get the value stored under the specifiedattributeNameas a string.String[]getStringArray(String attributeName) Get the value stored under the specifiedattributeNameas an array of strings.toString()从类继承的方法 java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values从类继承的方法 java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size从类继承的方法 java.util.AbstractMap
equals, hashCode从接口继承的方法 java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
字段详细资料
-
EMPTY_ARRAY
-
-
构造器详细资料
-
AnnotationAttributes
public AnnotationAttributes()Create a new, emptyAnnotationAttributesinstance. -
AnnotationAttributes
public AnnotationAttributes(int initialCapacity) Create a new, emptyAnnotationAttributesinstance with the given initial capacity to optimize performance.- 参数:
initialCapacity- initial size of the underlying map
-
AnnotationAttributes
Create a newAnnotationAttributesinstance, wrapping the provided map and all its key-value pairs.- 参数:
map- original source of annotation attribute key-value pairs- 另请参阅:
-
AnnotationAttributes
Create a newAnnotationAttributesinstance, wrapping the provided map and all its key-value pairs.- 参数:
other- original source of annotation attribute key-value pairs- 另请参阅:
-
AnnotationAttributes
Create a new, emptyAnnotationAttributesinstance for the specifiedannotationType.- 参数:
annotationType- the type of annotation represented by thisAnnotationAttributesinstance; nevernull
-
AnnotationAttributes
Create a new, emptyAnnotationAttributesinstance for the specifiedannotationType.- 参数:
annotationType- the annotation type name represented by thisAnnotationAttributesinstance; nevernullclassLoader- the ClassLoader to try to load the annotation type on, ornullto just store the annotation type name
-
-
方法详细资料
-
annotationType
Get the type of annotation represented by thisAnnotationAttributes.- 返回:
- the annotation type, or
nullif unknown
-
getString
Get the value stored under the specifiedattributeNameas a string.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getStringArray
Get the value stored under the specifiedattributeNameas an array of strings.If the value stored under the specified
attributeNameis a string, it will be wrapped in a single-element array before returning it.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getBoolean
Get the value stored under the specifiedattributeNameas a boolean.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getNumber
Get the value stored under the specifiedattributeNameas a number.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getEnum
Get the value stored under the specifiedattributeNameas an enum.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getClass
Get the value stored under the specifiedattributeNameas a class.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getClassArray
Get the value stored under the specifiedattributeNameas an array of classes.If the value stored under the specified
attributeNameis a class, it will be wrapped in a single-element array before returning it.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getAnnotation
Get theAnnotationAttributesstored under the specifiedattributeName.Note: if you expect an actual annotation, invoke
getAnnotation(String, Class)instead.- 参数:
attributeName- the name of the attribute to get; nevernullor empty- 返回:
- the
AnnotationAttributes - 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getAnnotation
Get the annotation of typeannotationTypestored under the specifiedattributeName.- 参数:
attributeName- the name of the attribute to get; nevernullor emptyannotationType- the expected annotation type; nevernull- 返回:
- the annotation
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getAnnotationArray
Get the array ofAnnotationAttributesstored under the specifiedattributeName.If the value stored under the specified
attributeNameis an instance ofAnnotationAttributes, 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; nevernullor empty- 返回:
- the array of
AnnotationAttributes - 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getAnnotationArray
Get the array of typeannotationTypestored under the specifiedattributeName.If the value stored under the specified
attributeNameis anAnnotation, it will be wrapped in a single-element array before returning it.- 参数:
attributeName- the name of the attribute to get; nevernullor emptyannotationType- the expected annotation type; nevernull- 返回:
- the annotation array
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
getRequiredAttribute
Get the value stored under the specifiedattributeName, ensuring that the value is of theexpectedType.If the
expectedTypeis an array and the value stored under the specifiedattributeNameis a single element of the component type of the expected array type, the single element will be wrapped in a single-element array of the appropriate type before returning it.- 参数:
attributeName- the name of the attribute to get; nevernullor emptyexpectedType- the expected type; nevernull- 返回:
- the value
- 抛出:
IllegalArgumentException- if the attribute does not exist or if it is not of the expected type
-
toString
- 覆盖:
toString在类中AbstractMap<String,Object>
-
fromMap
Return anAnnotationAttributesinstance based on the given map.If the map is already an
AnnotationAttributesinstance, 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 theAnnotationAttributes(Map)constructor.- 参数:
map- original source of annotation attribute key-value pairs
-
fromMetadata
@Nullable public static AnnotationAttributes fromMetadata(AnnotatedTypeMetadata metadata, Class<?> annotationClass) -
fromMetadata
@Nullable public static AnnotationAttributes fromMetadata(AnnotatedTypeMetadata metadata, String annotationClassName)
-