Package no.digipost.util
Class Attribute<V>
java.lang.Object
no.digipost.util.Attribute<V>
- Type Parameters:
V- The type of the object this attribute is mapping.
- All Implemented Interfaces:
Serializable,GetsNamedValue<V>,SetsNamedValue<V>
public final class Attribute<V>
extends Object
implements GetsNamedValue<V>, SetsNamedValue<V>, Serializable
An
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.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface no.digipost.util.GetsNamedValue
GetsNamedValue.NotFound -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface no.digipost.util.GetsNamedValue
getFrom, requireFrom, requireFromMethods inherited from interface no.digipost.util.SetsNamedValue
setOn
-
Field Details
-
name
The name of this attribute.
-
-
Constructor Details
-
Attribute
-
-
Method Details
-
withName
Create a new attribute of the same type with another name.- Parameters:
anotherName- the name for the new attribute- Returns:
- the new attribute instance. If the given name is equal to this attribute's name, the same instance is returned.
- See Also:
-
withValue
Bundle an attribute with an associated value in aTuple.- Parameters:
value- the value to associate with the attribute- Returns:
- a tuple containing the attribute and the value.
-
setOn
- Specified by:
setOnin interfaceSetsNamedValue<V>
-
getFrom
- Specified by:
getFromin interfaceGetsNamedValue<V>
-
toString
-
equals
-
hashCode
public int hashCode()
-