Package org.apache.sis.feature
Class MultiValuedAssociation
java.lang.Object
org.apache.sis.feature.Property
org.apache.sis.feature.Field<AbstractFeature>
org.apache.sis.feature.AbstractAssociation
org.apache.sis.feature.MultiValuedAssociation
- All Implemented Interfaces:
Serializable
,Cloneable
An instance of an association role containing an arbitrary number of values.
Note: in the common case where the association role
restricts the cardinality to [0 … 1], the
SingletonAssociation
implementation consumes less memory.Limitations
- Multi-threading:
MultiValuedAssociation
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.
- Since:
- 0.5
- Version:
- 0.6
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.private CheckedArrayList<AbstractFeature>
The association values.Fields inherited from class org.apache.sis.feature.AbstractAssociation
role
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new association of the given role.MultiValuedAssociation
(DefaultAssociationRole role, Object values) Creates a new association of the given role initialized to the given values. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this association.boolean
Compares this association with the given object for equality.getValue()
Returns the feature, ornull
if none.Returns all features, or an empty collection if none.int
hashCode()
Returns a hash code value for this association.void
setValue
(AbstractFeature value) Sets the feature.void
setValues
(Collection<? extends AbstractFeature> newValues) Sets the feature values.Methods inherited from class org.apache.sis.feature.AbstractAssociation
create, create, ensureValid, getName, getRole, 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 association values.
-
-
Constructor Details
-
MultiValuedAssociation
Creates a new association of the given role.- Parameters:
role
- Information about the association.
-
MultiValuedAssociation
MultiValuedAssociation(DefaultAssociationRole role, Object values) Creates a new association of the given role initialized to the given values.- Parameters:
role
- Information about the association.values
- The initial values, ornull
for initializing to an empty list.
-
-
Method Details
-
getValue
Returns the feature, ornull
if none.- Specified by:
getValue
in classAbstractAssociation
- Returns:
- the feature (may be
null
). - Throws:
IllegalStateException
- if this association contains more than one value.- See Also:
-
getValues
Returns all features, or an empty collection if none. The returned collection is live: changes in the returned collection will be reflected immediately in thisAssociation
instance, and conversely.- Overrides:
getValues
in classAbstractAssociation
- Returns:
- the features in a live collection.
-
setValue
Sets the feature.- Specified by:
setValue
in classAbstractAssociation
- Parameters:
value
- the new value, ornull
for removing all values from this association.- See Also:
-
setValues
Sets the feature values. All previous values are replaced by the given collection.- Overrides:
setValues
in classAbstractAssociation
- Parameters:
newValues
- the new values.
-
clone
Returns a copy of this association. This implementation returns a shallow copy: the association values are not cloned.- Overrides:
clone
in classAbstractAssociation
- Returns:
- a clone of this association.
- Throws:
CloneNotSupportedException
- if this association cannot be cloned.
-
hashCode
public int hashCode()Returns a hash code value for this association. -
equals
Compares this association with the given object for equality.
-