Interface AttributeMap<V>
- All Superinterfaces:
MapAdaptable<String,
V>
- All Known Subinterfaces:
MutableAttributeMap<V>
,SharedAttributeMap<V>
- All Known Implementing Classes:
LocalAttributeMap
,LocalSharedAttributeMap
An immutable interface for accessing attributes in a backing map with string keys.
Implementations can optionally support listeners
that will be notified when
they're bound in or unbound from the map.
- Author:
- Keith Donald
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Does the attribute with the provided name exist in this map?boolean
Does the attribute with the provided name exist in this map and is its value of the specified required type?Get an attribute value out of this map, returningnull
if not found.<T extends V>
TGet an attribute value, asserting the value is of the required type.<T extends V>
TGet an attribute value, asserting the value is of the required type and returning the default value if not found.Get an attribute value, returning the default value if no value is found.<T extends V>
T[]Returns an array attribute value in the map and makes sure it is of the required type.getBoolean
(String attributeName) Returns a boolean attribute value in the map, returningnull
if no value was found.getBoolean
(String attributeName, Boolean defaultValue) Returns a boolean attribute value in the map, returning the default value if no value was found.getCollection
(String attributeName) Returns a collection attribute value in the map.<T extends Collection<V>>
TgetCollection
(String attributeName, Class<T> requiredType) Returns a collection attribute value in the map and make sure it is of the required type.getInteger
(String attributeName) Returns an integer attribute value in the map, returningnull
if no value was found.getInteger
(String attributeName, Integer defaultValue) Returns an integer attribute value in the map, returning the default value if no value was found.Returns a long attribute value in the map, returningnull
if no value was found.Returns a long attribute value in the map, returning the default value if no value was found.<T extends Number>
TReturns a number attribute value in the map that is of the specified type, returningnull
if no value was found.<T extends Number>
TReturns a number attribute value in the map of the specified type, returning the default value if no value was found.getRequired
(String attributeName) Get the value of a required attribute, throwing an exception of no attribute is found.<T extends V>
TgetRequired
(String attributeName, Class<T> requiredType) Get the value of a required attribute and make sure it is of the required type.<T extends V>
T[]getRequiredArray
(String attributeName, Class<? extends T[]> requiredType) Returns an array attribute value in the map, throwing an exception if the attribute is not present or not an array of the required type.getRequiredBoolean
(String attributeName) Returns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the correct type.getRequiredCollection
(String attributeName) Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection.<T extends Collection<V>>
TgetRequiredCollection
(String attributeName, Class<T> requiredType) Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection of the required type.getRequiredInteger
(String attributeName) Returns an integer attribute value in the map, throwing an exception if the attribute is not present and of the correct type.getRequiredLong
(String attributeName) Returns a long attribute value in the map, throwing an exception if the attribute is not present and of the correct type.<T extends Number>
TgetRequiredNumber
(String attributeName, Class<T> requiredType) Returns a number attribute value in the map, throwing an exception if the attribute is not present and of the correct type.getRequiredString
(String attributeName) Returns a string attribute value in the map, throwing an exception if the attribute is not present and of the correct type.Returns a string attribute value in the map, returningnull
if no value was found.Returns a string attribute value in the map, returning the default value if no value was found.boolean
isEmpty()
Is this attribute map empty with a size of 0?int
size()
Returns the size of this map.union
(AttributeMap<? extends V> attributes) Returns a new attribute map containing the union of this map with the provided map.Methods inherited from interface org.springframework.binding.collection.MapAdaptable
asMap
-
Method Details
-
get
Get an attribute value out of this map, returningnull
if not found.- Parameters:
attributeName
- the attribute name- Returns:
- the attribute value
-
size
int size()Returns the size of this map.- Returns:
- the number of entries in the map
-
isEmpty
boolean isEmpty()Is this attribute map empty with a size of 0?- Returns:
- true if empty, false if not
-
contains
Does the attribute with the provided name exist in this map?- Parameters:
attributeName
- the attribute name- Returns:
- true if so, false otherwise
-
contains
boolean contains(String attributeName, Class<? extends V> requiredType) throws IllegalArgumentException Does the attribute with the provided name exist in this map and is its value of the specified required type?- Parameters:
attributeName
- the attribute namerequiredType
- the required class of the attribute value- Returns:
- true if so, false otherwise
- Throws:
IllegalArgumentException
- when the value is not of the required type
-
get
Get an attribute value, returning the default value if no value is found.- Parameters:
attributeName
- the name of the attributedefaultValue
- the default value- Returns:
- the attribute value, falling back to the default if no such attribute exists
-
get
Get an attribute value, asserting the value is of the required type.- Parameters:
attributeName
- the name of the attributerequiredType
- the required type of the attribute value- Returns:
- the attribute value, or null if not found
- Throws:
IllegalArgumentException
- when the value is not of the required type
-
get
<T extends V> T get(String attributeName, Class<T> requiredType, T defaultValue) throws IllegalStateException Get an attribute value, asserting the value is of the required type and returning the default value if not found.- Parameters:
attributeName
- the name of the attributerequiredType
- the value required typedefaultValue
- the default value- Returns:
- the attribute value, or the default if not found
- Throws:
IllegalArgumentException
- when the value (if found) is not of the required typeIllegalStateException
-
getRequired
Get the value of a required attribute, throwing an exception of no attribute is found.- Parameters:
attributeName
- the name of the attribute- Returns:
- the attribute value
- Throws:
IllegalArgumentException
- when the attribute is not found
-
getRequired
<T extends V> T getRequired(String attributeName, Class<T> requiredType) throws IllegalArgumentException Get the value of a required attribute and make sure it is of the required type.- Parameters:
attributeName
- name of the attribute to getrequiredType
- the required type of the attribute value- Returns:
- the attribute value
- Throws:
IllegalArgumentException
- when the attribute is not found or not of the required type
-
getString
Returns a string attribute value in the map, returningnull
if no value was found.- Parameters:
attributeName
- the attribute name- Returns:
- the string attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a string
-
getString
Returns a string attribute value in the map, returning the default value if no value was found.- Parameters:
attributeName
- the attribute namedefaultValue
- the default- Returns:
- the string attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a string
-
getRequiredString
Returns a string attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Parameters:
attributeName
- the attribute name- Returns:
- the string attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or present but not a string
-
getCollection
Returns a collection attribute value in the map.- Parameters:
attributeName
- the attribute name- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a collection
-
getCollection
<T extends Collection<V>> T getCollection(String attributeName, Class<T> requiredType) throws IllegalArgumentException Returns a collection attribute value in the map and make sure it is of the required type.- Parameters:
attributeName
- the attribute namerequiredType
- the required type of the attribute value- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a collection of the required type
-
getRequiredCollection
Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection.- Parameters:
attributeName
- the attribute name- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or is present but not a collection
-
getRequiredCollection
<T extends Collection<V>> T getRequiredCollection(String attributeName, Class<T> requiredType) throws IllegalArgumentException Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection of the required type.- Parameters:
attributeName
- the attribute namerequiredType
- the required collection type- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or is present but not a collection of the required type
-
getArray
<T extends V> T[] getArray(String attributeName, Class<? extends T[]> requiredType) throws IllegalArgumentException Returns an array attribute value in the map and makes sure it is of the required type.- Parameters:
attributeName
- the attribute namerequiredType
- the required type of the attribute value- Returns:
- the array attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not an array of the required type
-
getRequiredArray
<T extends V> T[] getRequiredArray(String attributeName, Class<? extends T[]> requiredType) throws IllegalArgumentException Returns an array attribute value in the map, throwing an exception if the attribute is not present or not an array of the required type.- Parameters:
attributeName
- the attribute namerequiredType
- the required array type- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or is present but not a array of the required type
-
getNumber
<T extends Number> T getNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException Returns a number attribute value in the map that is of the specified type, returningnull
if no value was found.- Parameters:
attributeName
- the attribute namerequiredType
- the required number type- Returns:
- the number attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a number of the required type
-
getNumber
<T extends Number> T getNumber(String attributeName, Class<T> requiredType, T defaultValue) throws IllegalArgumentException Returns a number attribute value in the map of the specified type, returning the default value if no value was found.- Parameters:
attributeName
- the attribute namedefaultValue
- the default- Returns:
- the number attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a number of the required type
-
getRequiredNumber
<T extends Number> T getRequiredNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException Returns a number attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Parameters:
attributeName
- the attribute name- Returns:
- the number attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or present but not a number of the required type
-
getInteger
Returns an integer attribute value in the map, returningnull
if no value was found.- Parameters:
attributeName
- the attribute name- Returns:
- the integer attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not an integer
-
getInteger
Returns an integer attribute value in the map, returning the default value if no value was found.- Parameters:
attributeName
- the attribute namedefaultValue
- the default- Returns:
- the integer attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not an integer
-
getRequiredInteger
Returns an integer attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Parameters:
attributeName
- the attribute name- Returns:
- the integer attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or present but not an integer
-
getLong
Returns a long attribute value in the map, returningnull
if no value was found.- Parameters:
attributeName
- the attribute name- Returns:
- the long attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a long
-
getLong
Returns a long attribute value in the map, returning the default value if no value was found.- Parameters:
attributeName
- the attribute namedefaultValue
- the default- Returns:
- the long attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a long
-
getRequiredLong
Returns a long attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Parameters:
attributeName
- the attribute name- Returns:
- the long attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or present but not a long
-
getBoolean
Returns a boolean attribute value in the map, returningnull
if no value was found.- Parameters:
attributeName
- the attribute name- Returns:
- the long attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a boolean
-
getBoolean
Returns a boolean attribute value in the map, returning the default value if no value was found.- Parameters:
attributeName
- the attribute namedefaultValue
- the default- Returns:
- the boolean attribute value
- Throws:
IllegalArgumentException
- if the attribute is present but not a boolean
-
getRequiredBoolean
Returns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Parameters:
attributeName
- the attribute name- Returns:
- the boolean attribute value
- Throws:
IllegalArgumentException
- if the attribute is not present or present but is not a boolean
-
union
Returns a new attribute map containing the union of this map with the provided map.- Parameters:
attributes
- the map to combine with this map- Returns:
- a new, combined map
-