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:
MultiValuedAttributeinstances 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 longFor 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.booleanCompares this attribute with the given object for equality.getValue()Returns the attribute value, ornullif none.Returns all attribute values, or an empty collection if none.inthashCode()Returns a hash code value for this attribute.voidSets the attribute value.voidsetValues(Collection<? extends V> newValues) Sets the attribute values.Methods inherited from class org.apache.sis.feature.AbstractAttribute
characteristics, characteristicsReadOnly, create, create, getName, getType, quality, toStringMethods 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 anullvalue 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, ornullfor initializing to an empty list.
-
-
Method Details
-
getValue
Returns the attribute value, ornullif none.- Specified by:
getValuein 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 thisAttributeinstance, and conversely.- Overrides:
getValuesin classAbstractAttribute<V>- Returns:
- the attribute values in a live collection.
-
setValue
Sets the attribute value.- Specified by:
setValuein classAbstractAttribute<V>- Parameters:
value- the new value, ornullfor removing all values from this attribute.- See Also:
-
setValues
Sets the attribute values. All previous values are replaced by the given collection.- Overrides:
setValuesin 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:
clonein 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.
-