Class SingletonAttribute<V>

Type Parameters:
V - the type of the attribute value.
All Implemented Interfaces:
Serializable, Cloneable

final class SingletonAttribute<V> extends AbstractAttribute<V> implements Cloneable
An instance of an attribute type containing at most one value. The majority of features types contain attributes restricted to such [0 … 1] cardinality. While MultiValuedAttribute would be suitable to all cases, this SingletonAttribute consumes less memory.

Limitations

  • Multi-threading: SingletonAttribute instances are not thread-safe. Synchronization, if needed, shall be done externally by the caller.
  • Cloning: this class support shallow cloning only: the attribute is cloned, but not its value.
Since:
0.5
Version:
0.8
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • value

      private V value
      The attribute value, or null if none.
  • Constructor Details

    • SingletonAttribute

      public SingletonAttribute(DefaultAttributeType<V> type)
      Creates a new attribute of the given type initialized to the default value.
      Parameters:
      type - information about the attribute (base Java class, domain of values, etc.).
    • SingletonAttribute

      SingletonAttribute(DefaultAttributeType<V> type, Object value)
      Creates a new attribute of the given type initialized to the given value. Note that a null value may not be the same as the default value.
      Parameters:
      type - information about the attribute (base Java class, domain of values, etc.).
      value - the initial value (may be null).
  • Method Details