HasAttributes
public interface AttributeContainer extends HasAttributes
attributes
, which are
strongly typed named entities. Such a container is responsible for storing and
getting attributes in a type safe way. In particular, attributes are strongly typed,
meaning that when we get a value from the container, the returned value type is
inferred from the type of the attribute. In a way, an attribute container is
similar to a Map
where the entry is a "typed String" and the value
is of the string type. However the set of methods available to the container is
much more limited.
It is not allowed to have two attributes with the same name but different types in
the container.Modifier and Type | Method | Description |
---|---|---|
<T> AttributeContainer |
attribute(Attribute<T> key,
T value) |
Sets an attribute value.
|
boolean |
contains(Attribute<?> key) |
Tells if a specific attribute is found in this container.
|
<T> T |
getAttribute(Attribute<T> key) |
Returns the value of an attribute found in this container, or
null if
this container doesn't have it. |
boolean |
isEmpty() |
Returns true if this container is empty.
|
Set<Attribute<?>> |
keySet() |
Returns the set of attribute keys of this container.
|
getAttributes
Set<Attribute<?>> keySet()
<T> AttributeContainer attribute(Attribute<T> key, T value)
null
as
an attribute value.T
- the type of the attributekey
- the attribute keyvalue
- the attribute value@Nullable <T> T getAttribute(Attribute<T> key)
null
if
this container doesn't have it.T
- the type of the attributekey
- the attribute keyboolean isEmpty()
boolean contains(Attribute<?> key)
key
- the key of the attribute