public class LocalAttributeMap extends Object implements MutableAttributeMap, Serializable
| Constructor and Description |
|---|
LocalAttributeMap()
Creates a new attribute map, initially empty.
|
LocalAttributeMap(int size,
int loadFactor)
Creates a new attribute map, initially empty.
|
LocalAttributeMap(Map map)
Creates a new attribute map wrapping the specified map.
|
LocalAttributeMap(String attributeName,
Object attributeValue)
Creates a new attribute map with a single entry.
|
| Modifier and Type | Method and Description |
|---|---|
Map |
asMap()
Returns this object's contents as a
Map. |
MutableAttributeMap |
clear()
Remove all attributes in this map.
|
boolean |
contains(String attributeName)
Does the attribute with the provided name exist in this map?
|
boolean |
contains(String attributeName,
Class requiredType)
Does the attribute with the provided name exist in this map and is its value of the specified required type?
|
boolean |
equals(Object o) |
Object |
extract(String attributeName)
Extract an attribute from this map, getting it and removing it in a single operation.
|
Object |
get(String attributeName)
Get an attribute value out of this map, returning
null if not found. |
Object |
get(String attributeName,
Class requiredType)
Get an attribute value, asserting the value is of the required type.
|
Object |
get(String attributeName,
Class requiredType,
Object defaultValue)
Get an attribute value, asserting the value is of the required type and returning the default value if not found.
|
Object |
get(String attributeName,
Object defaultValue)
Get an attribute value, returning the default value if no value is found.
|
Object[] |
getArray(String attributeName,
Class requiredType)
Returns an array attribute value in the map and makes sure it is of the required type.
|
Boolean |
getBoolean(String attributeName)
Returns a boolean attribute value in the map, returning
null if no value was found. |
Boolean |
getBoolean(String attributeName,
Boolean defaultValue)
Returns a boolean attribute value in the map, returning the default value if no value was found.
|
Collection |
getCollection(String attributeName)
Returns a collection attribute value in the map.
|
Collection |
getCollection(String attributeName,
Class requiredType)
Returns a collection attribute value in the map and make sure it is of the required type.
|
Integer |
getInteger(String attributeName)
Returns an integer attribute value in the map, returning
null if no value was found. |
Integer |
getInteger(String attributeName,
Integer defaultValue)
Returns an integer attribute value in the map, returning the default value if no value was found.
|
Long |
getLong(String attributeName)
Returns a long attribute value in the map, returning
null if no value was found. |
Long |
getLong(String attributeName,
Long defaultValue)
Returns a long attribute value in the map, returning the default value if no value was found.
|
Number |
getNumber(String attributeName,
Class requiredType)
Returns a number attribute value in the map that is of the specified type, returning
null if no
value was found. |
Number |
getNumber(String attributeName,
Class requiredType,
Number defaultValue)
Returns a number attribute value in the map of the specified type, returning the default value if no value was
found.
|
Object |
getRequired(String attributeName)
Get the value of a required attribute, throwing an exception of no attribute is found.
|
Object |
getRequired(String attributeName,
Class requiredType)
Get the value of a required attribute and make sure it is of the required type.
|
Object[] |
getRequiredArray(String attributeName,
Class 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.
|
Boolean |
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.
|
Collection |
getRequiredCollection(String attributeName)
Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a
collection.
|
Collection |
getRequiredCollection(String attributeName,
Class 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.
|
Integer |
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.
|
Long |
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.
|
Number |
getRequiredNumber(String attributeName,
Class requiredType)
Returns a number attribute value in the map, throwing an exception if the attribute is not present and of the
correct type.
|
String |
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.
|
String |
getString(String attributeName)
Returns a string attribute value in the map, returning
null if no value was found. |
String |
getString(String attributeName,
String defaultValue)
Returns a string attribute value in the map, returning the default value if no value was found.
|
int |
hashCode() |
boolean |
isEmpty()
Is this attribute map empty with a size of 0?
|
Object |
put(String attributeName,
Object attributeValue)
Put the attribute into this map.
|
MutableAttributeMap |
putAll(AttributeMap attributes)
Put all the attributes into this map.
|
Object |
remove(String attributeName)
Remove an attribute from this map.
|
MutableAttributeMap |
removeAll(MutableAttributeMap attributes)
Remove all attributes in the map provided from this map.
|
MutableAttributeMap |
replaceWith(AttributeMap attributes)
Replace the contents of this attribute map with the contents of the provided collection.
|
int |
size()
Returns the size of this map.
|
String |
toString() |
AttributeMap |
union(AttributeMap attributes)
Returns a new attribute map containing the union of this map with the provided map.
|
public LocalAttributeMap()
public LocalAttributeMap(int size,
int loadFactor)
size - the initial sizeloadFactor - the load factorpublic LocalAttributeMap(String attributeName, Object attributeValue)
public LocalAttributeMap(Map map)
public Map asMap()
MapAdaptableMap. The returned map may or may not be modifiable depending on this
implementation.
Warning: this operation may be called frequently; if so care should be taken so that the map contents (if calculated) be cached as appropriate.
asMap in interface MapAdaptablepublic int size()
AttributeMapsize in interface AttributeMappublic Object get(String attributeName)
AttributeMapnull if not found.get in interface AttributeMapattributeName - the attribute namepublic boolean isEmpty()
AttributeMapisEmpty in interface AttributeMappublic boolean contains(String attributeName)
AttributeMapcontains in interface AttributeMapattributeName - the attribute namepublic boolean contains(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapcontains in interface AttributeMapattributeName - the attribute namerequiredType - the required class of the attribute valueIllegalArgumentException - when the value is not of the required typepublic Object get(String attributeName, Object defaultValue)
AttributeMapget in interface AttributeMapattributeName - the name of the attributedefaultValue - the default valuepublic Object get(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapget in interface AttributeMapattributeName - the name of the attributerequiredType - the required type of the attribute valueIllegalArgumentException - when the value is not of the required typepublic Object get(String attributeName, Class requiredType, Object defaultValue) throws IllegalStateException
AttributeMapget in interface AttributeMapattributeName - the name of the attributerequiredType - the value required typedefaultValue - the default valueIllegalStateExceptionpublic Object getRequired(String attributeName) throws IllegalArgumentException
AttributeMapgetRequired in interface AttributeMapattributeName - the name of the attributeIllegalArgumentException - when the attribute is not foundpublic Object getRequired(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetRequired in interface AttributeMapattributeName - name of the attribute to getrequiredType - the required type of the attribute valueIllegalArgumentException - when the attribute is not found or not of the required typepublic String getString(String attributeName) throws IllegalArgumentException
AttributeMapnull if no value was found.getString in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is present but not a stringpublic String getString(String attributeName, String defaultValue) throws IllegalArgumentException
AttributeMapgetString in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultIllegalArgumentException - if the attribute is present but not a stringpublic String getRequiredString(String attributeName) throws IllegalArgumentException
AttributeMapgetRequiredString in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or present but not a stringpublic Collection getCollection(String attributeName) throws IllegalArgumentException
AttributeMapgetCollection in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is present but not a collectionpublic Collection getCollection(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetCollection in interface AttributeMapattributeName - the attribute namerequiredType - the required type of the attribute valueIllegalArgumentException - if the attribute is present but not a collection of the required typepublic Collection getRequiredCollection(String attributeName) throws IllegalArgumentException
AttributeMapgetRequiredCollection in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or is present but not a collectionpublic Collection getRequiredCollection(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetRequiredCollection in interface AttributeMapattributeName - the attribute namerequiredType - the required collection typeIllegalArgumentException - if the attribute is not present or is present but not a collection of the
required typepublic Object[] getArray(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetArray in interface AttributeMapattributeName - the attribute namerequiredType - the required type of the attribute valueIllegalArgumentException - if the attribute is present but not an array of the required typepublic Object[] getRequiredArray(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetRequiredArray in interface AttributeMapattributeName - the attribute namerequiredType - the required array typeIllegalArgumentException - if the attribute is not present or is present but not a array of the required
typepublic Number getNumber(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapnull if no
value was found.getNumber in interface AttributeMapattributeName - the attribute namerequiredType - the required number typeIllegalArgumentException - if the attribute is present but not a number of the required typepublic Number getNumber(String attributeName, Class requiredType, Number defaultValue) throws IllegalArgumentException
AttributeMapgetNumber in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultIllegalArgumentException - if the attribute is present but not a number of the required typepublic Number getRequiredNumber(String attributeName, Class requiredType) throws IllegalArgumentException
AttributeMapgetRequiredNumber in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or present but not a number of the required typepublic Integer getInteger(String attributeName) throws IllegalArgumentException
AttributeMapnull if no value was found.getInteger in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is present but not an integerpublic Integer getInteger(String attributeName, Integer defaultValue) throws IllegalArgumentException
AttributeMapgetInteger in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultIllegalArgumentException - if the attribute is present but not an integerpublic Integer getRequiredInteger(String attributeName) throws IllegalArgumentException
AttributeMapgetRequiredInteger in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or present but not an integerpublic Long getLong(String attributeName) throws IllegalArgumentException
AttributeMapnull if no value was found.getLong in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is present but not a longpublic Long getLong(String attributeName, Long defaultValue) throws IllegalArgumentException
AttributeMapgetLong in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultIllegalArgumentException - if the attribute is present but not a longpublic Long getRequiredLong(String attributeName) throws IllegalArgumentException
AttributeMapgetRequiredLong in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or present but not a longpublic Boolean getBoolean(String attributeName) throws IllegalArgumentException
AttributeMapnull if no value was found.getBoolean in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is present but not a booleanpublic Boolean getBoolean(String attributeName, Boolean defaultValue) throws IllegalArgumentException
AttributeMapgetBoolean in interface AttributeMapattributeName - the attribute namedefaultValue - the defaultIllegalArgumentException - if the attribute is present but not a booleanpublic Boolean getRequiredBoolean(String attributeName) throws IllegalArgumentException
AttributeMapgetRequiredBoolean in interface AttributeMapattributeName - the attribute nameIllegalArgumentException - if the attribute is not present or present but is not a booleanpublic AttributeMap union(AttributeMap attributes)
AttributeMapunion in interface AttributeMapattributes - the map to combine with this mappublic Object put(String attributeName, Object attributeValue)
MutableAttributeMap
If the attribute value is an AttributeMapBindingListener this map will publish
binding events such as on "bind" and "unbind" if supported.
Note: not all MutableAttributeMap implementations support this.
put in interface MutableAttributeMapattributeName - the attribute nameattributeValue - the attribute valuenull of there was no previous valuepublic MutableAttributeMap putAll(AttributeMap attributes)
MutableAttributeMapputAll in interface MutableAttributeMapattributes - the attributes to put into this mappublic MutableAttributeMap removeAll(MutableAttributeMap attributes)
MutableAttributeMapremoveAll in interface MutableAttributeMapattributes - the attributes to remove from this mappublic Object remove(String attributeName)
MutableAttributeMapremove in interface MutableAttributeMapattributeName - the name of the attribute to removepublic Object extract(String attributeName)
MutableAttributeMapextract in interface MutableAttributeMapattributeName - the attribute namenull of there was no valuepublic MutableAttributeMap clear() throws UnsupportedOperationException
MutableAttributeMapclear in interface MutableAttributeMapUnsupportedOperationExceptionpublic MutableAttributeMap replaceWith(AttributeMap attributes) throws UnsupportedOperationException
MutableAttributeMapreplaceWith in interface MutableAttributeMapattributes - the attribute collectionUnsupportedOperationException