Package org.apache.sis.feature
Class SingletonAttribute<V>
java.lang.Object
org.apache.sis.feature.Property
org.apache.sis.feature.Field<V>
org.apache.sis.feature.AbstractAttribute<V>
org.apache.sis.feature.SingletonAttribute<V>
- Type Parameters:
V
- the type of the attribute value.
- All Implemented Interfaces:
Serializable
,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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.private V
The attribute value, ornull
if none.Fields inherited from class org.apache.sis.feature.AbstractAttribute
type
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new attribute of the given type initialized to the default value.SingletonAttribute
(DefaultAttributeType<V> type, Object value) Creates a new attribute of the given type initialized to the given value. -
Method Summary
Methods inherited from class org.apache.sis.feature.AbstractAttribute
characteristics, characteristicsReadOnly, clone, create, create, getName, getType, getValues, quality, setValues, toString
Methods inherited from class org.apache.sis.feature.Field
isDeprecated, isSingleton
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
value
The attribute value, ornull
if none.
-
-
Constructor Details
-
SingletonAttribute
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 anull
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 benull
).
-
-
Method Details
-
getValue
Returns the attribute value.- Specified by:
getValue
in classAbstractAttribute<V>
- Returns:
- the attribute value (may be
null
). - See Also:
-
setValue
Sets the attribute value.- Specified by:
setValue
in classAbstractAttribute<V>
- Parameters:
value
- the new value.- See Also:
-
hashCode
public int hashCode()Returns a hash code value for this attribute. -
equals
Compares this attribute with the given object for equality.
-