Class LocalAttributeMap<V>
java.lang.Object
org.springframework.webflow.core.collection.LocalAttributeMap<V>
- All Implemented Interfaces:
Serializable,org.springframework.binding.collection.MapAdaptable<String,,V> AttributeMap<V>,MutableAttributeMap<V>
- Direct Known Subclasses:
LocalSharedAttributeMap
A generic, mutable attribute map with string keys.
- Author:
- Keith Donald
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new attribute map, initially empty.LocalAttributeMap(int size, int loadFactor) Creates a new attribute map, initially empty.LocalAttributeMap(String attributeName, V attributeValue) Creates a new attribute map with a single entry.LocalAttributeMap(Map<String, V> map) Creates a new attribute map wrapping the specified map. -
Method Summary
Modifier and TypeMethodDescriptionasMap()clear()Remove all attributes in this map.booleanDoes the attribute with the provided name exist in this map?booleanDoes the attribute with the provided name exist in this map and is its value of the specified required type?Factory method that returns the target map storing the data in this attribute map.createTargetMap(int size, int loadFactor) Factory method that returns the target map storing the data in this attribute map.booleanExtract an attribute from this map, getting it and removing it in a single operation.Get an attribute value out of this map, returningnullif 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, returningnullif 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, returningnullif 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, returningnullif no value was found.Returns a long attribute value in the map, returning the default value if no value was found.Returns the wrapped, modifiable map implementation.<T extends Number>
TReturns a number attribute value in the map that is of the specified type, returningnullif 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, returningnullif no value was found.Returns a string attribute value in the map, returning the default value if no value was found.inthashCode()protected voidinitAttributes(Map<String, V> attributes) Initializes this attribute map.booleanisEmpty()Is this attribute map empty with a size of 0?Put the attribute into this map.putAll(AttributeMap<? extends V> attributes) Put all the attributes into this map.Remove an attribute from this map.removeAll(MutableAttributeMap<? extends V> attributes) Remove all attributes in the map provided from this map.replaceWith(AttributeMap<? extends V> attributes) Replace the contents of this attribute map with the contents of the provided collection.intsize()Returns the size of this map.toString()union(AttributeMap<? extends V> attributes) Returns a new attribute map containing the union of this map with the provided map.
-
Constructor Details
-
LocalAttributeMap
public LocalAttributeMap()Creates a new attribute map, initially empty. -
LocalAttributeMap
public LocalAttributeMap(int size, int loadFactor) Creates a new attribute map, initially empty.- Parameters:
size- the initial sizeloadFactor- the load factor
-
LocalAttributeMap
Creates a new attribute map with a single entry. -
LocalAttributeMap
Creates a new attribute map wrapping the specified map.
-
-
Method Details
-
asMap
-
size
public int size()Description copied from interface:AttributeMapReturns the size of this map.- Specified by:
sizein interfaceAttributeMap<V>- Returns:
- the number of entries in the map
-
get
Description copied from interface:AttributeMapGet an attribute value out of this map, returningnullif not found.- Specified by:
getin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the attribute value
-
isEmpty
public boolean isEmpty()Description copied from interface:AttributeMapIs this attribute map empty with a size of 0?- Specified by:
isEmptyin interfaceAttributeMap<V>- Returns:
- true if empty, false if not
-
contains
Description copied from interface:AttributeMapDoes the attribute with the provided name exist in this map?- Specified by:
containsin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- true if so, false otherwise
-
contains
public boolean contains(String attributeName, Class<? extends V> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapDoes the attribute with the provided name exist in this map and is its value of the specified required type?- Specified by:
containsin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapGet an attribute value, returning the default value if no value is found.- Specified by:
getin interfaceAttributeMap<V>- 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
public <T extends V> T get(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapGet an attribute value, asserting the value is of the required type.- Specified by:
getin interfaceAttributeMap<V>- 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
public <T extends V> T get(String attributeName, Class<T> requiredType, T defaultValue) throws IllegalStateException Description copied from interface:AttributeMapGet an attribute value, asserting the value is of the required type and returning the default value if not found.- Specified by:
getin interfaceAttributeMap<V>- 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:
IllegalStateException
-
getRequired
Description copied from interface:AttributeMapGet the value of a required attribute, throwing an exception of no attribute is found.- Specified by:
getRequiredin interfaceAttributeMap<V>- Parameters:
attributeName- the name of the attribute- Returns:
- the attribute value
- Throws:
IllegalArgumentException- when the attribute is not found
-
getRequired
public <T extends V> T getRequired(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapGet the value of a required attribute and make sure it is of the required type.- Specified by:
getRequiredin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a string attribute value in the map, returningnullif no value was found.- Specified by:
getStringin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the string attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a string
-
getString
Description copied from interface:AttributeMapReturns a string attribute value in the map, returning the default value if no value was found.- Specified by:
getStringin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute namedefaultValue- the default- Returns:
- the string attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a string
-
getRequiredString
Description copied from interface:AttributeMapReturns a string attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Specified by:
getRequiredStringin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a collection attribute value in the map.- Specified by:
getCollectionin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the collection attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a collection
-
getCollection
public <T extends Collection<V>> T getCollection(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a collection attribute value in the map and make sure it is of the required type.- Specified by:
getCollectionin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection.- Specified by:
getRequiredCollectionin interfaceAttributeMap<V>- 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
public <T extends Collection<V>> T getRequiredCollection(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a collection attribute value in the map, throwing an exception if the attribute is not present or not a collection of the required type.- Specified by:
getRequiredCollectionin interfaceAttributeMap<V>- 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
public <T extends V> T[] getArray(String attributeName, Class<? extends T[]> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns an array attribute value in the map and makes sure it is of the required type.- Specified by:
getArrayin interfaceAttributeMap<V>- 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
public <T extends V> T[] getRequiredArray(String attributeName, Class<? extends T[]> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns an array attribute value in the map, throwing an exception if the attribute is not present or not an array of the required type.- Specified by:
getRequiredArrayin interfaceAttributeMap<V>- 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
public <T extends Number> T getNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a number attribute value in the map that is of the specified type, returningnullif no value was found.- Specified by:
getNumberin interfaceAttributeMap<V>- 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
public <T extends Number> T getNumber(String attributeName, Class<T> requiredType, T defaultValue) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a number attribute value in the map of the specified type, returning the default value if no value was found.- Specified by:
getNumberin interfaceAttributeMap<V>- 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
public <T extends Number> T getRequiredNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a number attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Specified by:
getRequiredNumberin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns an integer attribute value in the map, returningnullif no value was found.- Specified by:
getIntegerin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the integer attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not an integer
-
getInteger
public Integer getInteger(String attributeName, Integer defaultValue) throws IllegalArgumentException Description copied from interface:AttributeMapReturns an integer attribute value in the map, returning the default value if no value was found.- Specified by:
getIntegerin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute namedefaultValue- the default- Returns:
- the integer attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not an integer
-
getRequiredInteger
Description copied from interface:AttributeMapReturns an integer attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Specified by:
getRequiredIntegerin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a long attribute value in the map, returningnullif no value was found.- Specified by:
getLongin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the long attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a long
-
getLong
Description copied from interface:AttributeMapReturns a long attribute value in the map, returning the default value if no value was found.- Specified by:
getLongin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute namedefaultValue- the default- Returns:
- the long attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a long
-
getRequiredLong
Description copied from interface:AttributeMapReturns a long attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Specified by:
getRequiredLongin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a boolean attribute value in the map, returningnullif no value was found.- Specified by:
getBooleanin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the long attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a boolean
-
getBoolean
public Boolean getBoolean(String attributeName, Boolean defaultValue) throws IllegalArgumentException Description copied from interface:AttributeMapReturns a boolean attribute value in the map, returning the default value if no value was found.- Specified by:
getBooleanin interfaceAttributeMap<V>- Parameters:
attributeName- the attribute namedefaultValue- the default- Returns:
- the boolean attribute value
- Throws:
IllegalArgumentException- if the attribute is present but not a boolean
-
getRequiredBoolean
Description copied from interface:AttributeMapReturns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the correct type.- Specified by:
getRequiredBooleanin interfaceAttributeMap<V>- 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
Description copied from interface:AttributeMapReturns a new attribute map containing the union of this map with the provided map.- Specified by:
unionin interfaceAttributeMap<V>- Parameters:
attributes- the map to combine with this map- Returns:
- a new, combined map
-
put
Description copied from interface:MutableAttributeMapPut the attribute into this map.If the attribute value is an
AttributeMapBindingListenerthis map will publishbinding eventssuch as on "bind" and "unbind" if supported.Note: not all
MutableAttributeMapimplementations support this.- Specified by:
putin interfaceMutableAttributeMap<V>- Parameters:
attributeName- the attribute nameattributeValue- the attribute value- Returns:
- the previous value of the attribute, or
nullof there was no previous value
-
putAll
Description copied from interface:MutableAttributeMapPut all the attributes into this map.- Specified by:
putAllin interfaceMutableAttributeMap<V>- Parameters:
attributes- the attributes to put into this map- Returns:
- this, to support call chaining
-
removeAll
Description copied from interface:MutableAttributeMapRemove all attributes in the map provided from this map.- Specified by:
removeAllin interfaceMutableAttributeMap<V>- Parameters:
attributes- the attributes to remove from this map- Returns:
- this, to support call chaining
-
remove
Description copied from interface:MutableAttributeMapRemove an attribute from this map.- Specified by:
removein interfaceMutableAttributeMap<V>- Parameters:
attributeName- the name of the attribute to remove- Returns:
- previous value associated with specified attribute name, or
nullif there was no mapping for the name
-
extract
Description copied from interface:MutableAttributeMapExtract an attribute from this map, getting it and removing it in a single operation.- Specified by:
extractin interfaceMutableAttributeMap<V>- Parameters:
attributeName- the attribute name- Returns:
- the value of the attribute, or
nullof there was no value
-
clear
Description copied from interface:MutableAttributeMapRemove all attributes in this map.- Specified by:
clearin interfaceMutableAttributeMap<V>- Returns:
- this, to support call chaining
- Throws:
UnsupportedOperationException
-
replaceWith
public MutableAttributeMap<V> replaceWith(AttributeMap<? extends V> attributes) throws UnsupportedOperationException Description copied from interface:MutableAttributeMapReplace the contents of this attribute map with the contents of the provided collection.- Specified by:
replaceWithin interfaceMutableAttributeMap<V>- Parameters:
attributes- the attribute collection- Returns:
- this, to support call chaining
- Throws:
UnsupportedOperationException
-
initAttributes
Initializes this attribute map.- Parameters:
attributes- the attributes
-
getMapInternal
Returns the wrapped, modifiable map implementation. -
createTargetMap
Factory method that returns the target map storing the data in this attribute map.- Returns:
- the target map
-
createTargetMap
Factory method that returns the target map storing the data in this attribute map.- Parameters:
size- the initial size of the maploadFactor- the load factor- Returns:
- the target map
-
equals
-
hashCode
public int hashCode() -
toString
-