Package org.apache.sis.feature
Class MultiValuedAttribute<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.MultiValuedAttribute<V>
- Type Parameters:
V
- the type of the attribute values.
- All Implemented Interfaces:
Serializable
,Cloneable
An instance of an attribute type containing an arbitrary number of values.
Note: in the common case where the attribute type
restricts the cardinality to [0 … 1], the
SingletonAttribute
implementation consumes less memory.Limitations
- Multi-threading:
MultiValuedAttribute
instances are not thread-safe. Synchronization, if needed, shall be done externally by the caller. - Serialization: serialized objects of this class are not guaranteed to be compatible with future versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.
- Cloning: this class support shallow cloning only: the attribute is cloned, but not the value elements.
- Since:
- 0.5
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.private CheckedArrayList<V>
The attribute values.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.MultiValuedAttribute
(DefaultAttributeType<V> type, Object values) Creates a new attribute of the given type initialized to the given values. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this attribute.boolean
Compares this attribute with the given object for equality.getValue()
Returns the attribute value, ornull
if none.Returns all attribute values, or an empty collection if none.int
hashCode()
Returns a hash code value for this attribute.void
Sets the attribute value.void
setValues
(Collection<? extends V> newValues) Sets the attribute values.Methods inherited from class org.apache.sis.feature.AbstractAttribute
characteristics, characteristicsReadOnly, create, create, getName, getType, quality, 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:
-
values
The attribute values.
-
-
Constructor Details
-
MultiValuedAttribute
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.).
-
MultiValuedAttribute
MultiValuedAttribute(DefaultAttributeType<V> type, Object values) Creates a new attribute of the given type initialized to the given values. 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.).values
- the initial values, ornull
for initializing to an empty list.
-
-
Method Details
-
getValue
Returns the attribute value, ornull
if none.- Specified by:
getValue
in classAbstractAttribute<V>
- Returns:
- the attribute value (may be
null
). - Throws:
IllegalStateException
- if this attribute contains more than one value.- See Also:
-
getValues
Returns all attribute values, or an empty collection if none. The returned collection is live: changes in the returned collection will be reflected immediately in thisAttribute
instance, and conversely.- Overrides:
getValues
in classAbstractAttribute<V>
- Returns:
- the attribute values in a live collection.
-
setValue
Sets the attribute value.- Specified by:
setValue
in classAbstractAttribute<V>
- Parameters:
value
- the new value, ornull
for removing all values from this attribute.- See Also:
-
setValues
Sets the attribute values. All previous values are replaced by the given collection.- Overrides:
setValues
in classAbstractAttribute<V>
- Parameters:
newValues
- the new values.
-
clone
Returns a copy of this attribute. This implementation returns a shallow copy: the attribute values are not cloned.- Overrides:
clone
in classAbstractAttribute<V>
- Returns:
- a clone of this attribute.
- Throws:
CloneNotSupportedException
- if this attribute cannot be cloned.
-
hashCode
public int hashCode()Returns a hash code value for this attribute. -
equals
Compares this attribute with the given object for equality.
-