public interface AttributeMap extends MapAdaptable
Implementations can optionally support listeners
that will be notified when
they're bound in or unbound from the map.
Modifier and Type | Method and Description |
---|---|
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?
|
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.
|
boolean |
isEmpty()
Is this attribute map empty with a size of 0?
|
int |
size()
Returns the size of this map.
|
AttributeMap |
union(AttributeMap attributes)
Returns a new attribute map containing the union of this map with the provided map.
|
asMap
Object get(String attributeName)
null
if not found.attributeName
- the attribute nameint size()
boolean isEmpty()
boolean contains(String attributeName)
attributeName
- the attribute nameboolean contains(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute namerequiredType
- the required class of the attribute valueIllegalArgumentException
- when the value is not of the required typeObject get(String attributeName, Object defaultValue)
attributeName
- the name of the attributedefaultValue
- the default valueObject get(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the name of the attributerequiredType
- the required type of the attribute valueIllegalArgumentException
- when the value is not of the required typeObject get(String attributeName, Class requiredType, Object defaultValue) throws IllegalStateException
attributeName
- the name of the attributerequiredType
- the value required typedefaultValue
- the default valueIllegalArgumentException
- when the value (if found) is not of the required typeIllegalStateException
Object getRequired(String attributeName) throws IllegalArgumentException
attributeName
- the name of the attributeIllegalArgumentException
- when the attribute is not foundObject getRequired(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- name of the attribute to getrequiredType
- the required type of the attribute valueIllegalArgumentException
- when the attribute is not found or not of the required typeString getString(String attributeName) throws IllegalArgumentException
null
if no value was found.attributeName
- the attribute nameIllegalArgumentException
- if the attribute is present but not a stringString getString(String attributeName, String defaultValue) throws IllegalArgumentException
attributeName
- the attribute namedefaultValue
- the defaultIllegalArgumentException
- if the attribute is present but not a stringString getRequiredString(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or present but not a stringCollection getCollection(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is present but not a collectionCollection getCollection(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute namerequiredType
- the required type of the attribute valueIllegalArgumentException
- if the attribute is present but not a collection of the required typeCollection getRequiredCollection(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or is present but not a collectionCollection getRequiredCollection(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute namerequiredType
- the required collection typeIllegalArgumentException
- if the attribute is not present or is present but not a collection of the
required typeObject[] getArray(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute namerequiredType
- the required type of the attribute valueIllegalArgumentException
- if the attribute is present but not an array of the required typeObject[] getRequiredArray(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute namerequiredType
- the required array typeIllegalArgumentException
- if the attribute is not present or is present but not a array of the required
typeNumber getNumber(String attributeName, Class requiredType) throws IllegalArgumentException
null
if no
value was found.attributeName
- the attribute namerequiredType
- the required number typeIllegalArgumentException
- if the attribute is present but not a number of the required typeNumber getNumber(String attributeName, Class requiredType, Number defaultValue) throws IllegalArgumentException
attributeName
- the attribute namedefaultValue
- the defaultIllegalArgumentException
- if the attribute is present but not a number of the required typeNumber getRequiredNumber(String attributeName, Class requiredType) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or present but not a number of the required typeInteger getInteger(String attributeName) throws IllegalArgumentException
null
if no value was found.attributeName
- the attribute nameIllegalArgumentException
- if the attribute is present but not an integerInteger getInteger(String attributeName, Integer defaultValue) throws IllegalArgumentException
attributeName
- the attribute namedefaultValue
- the defaultIllegalArgumentException
- if the attribute is present but not an integerInteger getRequiredInteger(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or present but not an integerLong getLong(String attributeName) throws IllegalArgumentException
null
if no value was found.attributeName
- the attribute nameIllegalArgumentException
- if the attribute is present but not a longLong getLong(String attributeName, Long defaultValue) throws IllegalArgumentException
attributeName
- the attribute namedefaultValue
- the defaultIllegalArgumentException
- if the attribute is present but not a longLong getRequiredLong(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or present but not a longBoolean getBoolean(String attributeName) throws IllegalArgumentException
null
if no value was found.attributeName
- the attribute nameIllegalArgumentException
- if the attribute is present but not a booleanBoolean getBoolean(String attributeName, Boolean defaultValue) throws IllegalArgumentException
attributeName
- the attribute namedefaultValue
- the defaultIllegalArgumentException
- if the attribute is present but not a booleanBoolean getRequiredBoolean(String attributeName) throws IllegalArgumentException
attributeName
- the attribute nameIllegalArgumentException
- if the attribute is not present or present but is not a booleanAttributeMap union(AttributeMap attributes)
attributes
- the map to combine with this map