public class AnnotationAttributes extends LinkedHashMap<String,Object>
LinkedHashMap subclass representing annotation attribute key/value
pairs as read by Spring's reflection- or ASM-based
AnnotationMetadata implementations,
AnnotationUtils, and AnnotatedElementUtils.
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.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
AnnotationAttributes()
Create a new, empty
AnnotationAttributes instance. |
AnnotationAttributes(Class<? extends Annotation> annotationType)
Create a new, empty
AnnotationAttributes instance for the
specified annotationType. |
AnnotationAttributes(int initialCapacity)
Create a new, empty
AnnotationAttributes instance with the given initial
capacity to optimize performance. |
AnnotationAttributes(Map<String,Object> map)
Create a new
AnnotationAttributes instance, wrapping the provided map
and all its key/value pairs. |
| Modifier and Type | Method and Description |
|---|---|
Class<? extends Annotation> |
annotationType()
Get the type of annotation represented by this
AnnotationAttributes
instance. |
static AnnotationAttributes |
fromMap(Map<String,Object> map)
Return an
AnnotationAttributes instance based on the given map. |
AnnotationAttributes |
getAnnotation(String attributeName) |
AnnotationAttributes[] |
getAnnotationArray(String attributeName) |
boolean |
getBoolean(String attributeName) |
<T> Class<? extends T> |
getClass(String attributeName) |
Class<?>[] |
getClassArray(String attributeName) |
<E extends Enum<?>> |
getEnum(String attributeName) |
<N extends Number> |
getNumber(String attributeName) |
String |
getString(String attributeName) |
String[] |
getStringArray(String attributeName) |
Object |
putIfAbsent(String key,
Object value)
Store the supplied
value in this map under the specified
key, unless a value is already stored under the key. |
String |
toString() |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, remove, remove, replace, replace, sizeequals, hashCodepublic AnnotationAttributes()
AnnotationAttributes instance.public AnnotationAttributes(Class<? extends Annotation> annotationType)
AnnotationAttributes instance for the
specified annotationType.annotationType - the type of annotation represented by this
AnnotationAttributes instancepublic AnnotationAttributes(int initialCapacity)
AnnotationAttributes instance with the given initial
capacity to optimize performance.initialCapacity - initial size of the underlying mappublic AnnotationAttributes(Map<String,Object> map)
AnnotationAttributes instance, wrapping the provided map
and all its key/value pairs.map - original source of annotation attribute key/value pairs to wrapfromMap(Map)public Class<? extends Annotation> annotationType()
AnnotationAttributes
instance.null if unknownpublic boolean getBoolean(String attributeName)
public AnnotationAttributes getAnnotation(String attributeName)
public AnnotationAttributes[] getAnnotationArray(String attributeName)
public Object putIfAbsent(String key, Object value)
value in this map under the specified
key, unless a value is already stored under the key.putIfAbsent in interface Map<String,Object>putIfAbsent in class HashMap<String,Object>key - the key under which to store the valuevalue - the value to storenull if no
value was previously stored in this mapLinkedHashMap.get(java.lang.Object),
HashMap.put(K, V)public String toString()
toString in class AbstractMap<String,Object>public static AnnotationAttributes fromMap(Map<String,Object> map)
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