Class 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:
    Serialized Form
    • Field Detail

      • name

        public final String name
        The name of this attribute.
    • Constructor Detail

      • Attribute

        public Attribute​(String name)
    • Method Detail

      • withName

        public Attribute<V> withName​(String anotherName)
        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:
        name
      • withValue

        public Tuple<Attribute<V>,​V> withValue​(V value)
        Bundle an attribute with an associated value in a Tuple.
        Parameters:
        value - the value to associate with the attribute
        Returns:
        a tuple containing the attribute and the value.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object