org.springframework.core.annotation
Class AnnotationAttributes
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,Object>
-
- org.springframework.core.annotation.AnnotationAttributes
-
- All Implemented Interfaces:
- Serializable, Cloneable, Map< String, Object>
public class AnnotationAttributes extends LinkedHashMap<String,Object>
LinkedHashMap
subclass representing annotation attribute key/value pairs as read by Spring's reflection- or ASM-basedAnnotationMetadata
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.- Since:
- 3.1.1
- Author:
- Chris Beams
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor Summary
Constructors Constructor and Description AnnotationAttributes()
Create a new, emptyAnnotationAttributes
instance.AnnotationAttributes(int initialCapacity)
Create a new, emptyAnnotationAttributes
instance with the given initial capacity to optimize performance.AnnotationAttributes(Map<String,Object> map)
Create a newAnnotationAttributes
instance, wrapping the provided map and all its key/value pairs.
Method Summary
Methods Modifier and Type Method and Description static AnnotationAttributes
fromMap(Map<String,Object> map)
Return anAnnotationAttributes
instance based on the given map; if the map is already anAnnotationAttributes
instance, it is casted and returned immediately without creating any new instance; otherwise create a new instance by wrapping the map with theAnnotationAttributes(Map)
constructor.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<?>>
EgetEnum(String attributeName)
<N extends Number>
NgetNumber(String attributeName)
String
getString(String attributeName)
String[]
getStringArray(String attributeName)
String
toString()
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
Constructor Detail
AnnotationAttributes
public AnnotationAttributes()
Create a new, emptyAnnotationAttributes
instance.
AnnotationAttributes
public AnnotationAttributes(int initialCapacity)
Create a new, emptyAnnotationAttributes
instance with the given initial capacity to optimize performance.- Parameters:
-
initialCapacity
- initial size of the underlying map
AnnotationAttributes
public AnnotationAttributes(Map<String,Object> map)
Create a newAnnotationAttributes
instance, wrapping the provided map and all its key/value pairs.- Parameters:
-
map
- original source of annotation attribute key/value pairs to wrap - See Also:
-
fromMap(Map)
Method Detail
fromMap
public static AnnotationAttributes fromMap(Map<String,Object> map)
Return anAnnotationAttributes
instance based on the given map; if the map is already anAnnotationAttributes
instance, it is casted and returned immediately without creating any new instance; otherwise create a new instance by wrapping the map with theAnnotationAttributes(Map)
constructor.- Parameters:
-
map
- original source of annotation attribute key/value pairs
getBoolean
public boolean getBoolean(String attributeName)
getAnnotation
public AnnotationAttributes getAnnotation(String attributeName)
getAnnotationArray
public AnnotationAttributes[] getAnnotationArray(String attributeName)
toString
public String toString()
- Overrides:
-
toString
in classAbstractMap<String,Object>