V - The type of the object this attribute is mapping.public final class Attribute<V> extends Object implements GetsNamedValue<V>, SetsNamedValue<V>, Serializable
Attribute defines a String-based name (or key) and the type of a value which
the name maps to. This construct offers pseudo-typesafe handling where objects of arbitrary
types are retrieved by name and must be manually casted.GetsNamedValue.NotFound| Modifier and Type | Field and Description |
|---|---|
String |
name
The name of this attribute.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Optional<V> |
getFrom(Function<String,?> getter) |
int |
hashCode() |
void |
setOn(BiConsumer<String,? super V> setter,
V value) |
String |
toString() |
Attribute<V> |
withName(String anotherName)
Create a new attribute of the same type with another name.
|
Tuple<Attribute<V>,V> |
withValue(V value)
Bundle an attribute with an associated value in a
Tuple. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFrom, requireFrom, requireFromsetOnpublic final String name
public Attribute(String name)
public Attribute<V> withName(String anotherName)
anotherName - the name for the new attributenamepublic Tuple<Attribute<V>,V> withValue(V value)
Tuple.value - the value to associate with the attributepublic void setOn(BiConsumer<String,? super V> setter, V value)
setOn in interface SetsNamedValue<V>public Optional<V> getFrom(Function<String,?> getter)
getFrom in interface GetsNamedValue<V>Copyright © 2018 Digipost. All rights reserved.