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:
MultiValuedAssociationinstances 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 longFor 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.booleanCompares this association with the given object for equality.getValue()Returns the feature, ornullif none.Returns all features, or an empty collection if none.inthashCode()Returns a hash code value for this association.voidsetValue(AbstractFeature value) Sets the feature.voidsetValues(Collection<? extends AbstractFeature> newValues) Sets the feature values.Methods inherited from class org.apache.sis.feature.AbstractAssociation
create, create, ensureValid, getName, getRole, 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 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, ornullfor initializing to an empty list.
-
-
Method Details
-
getValue
Returns the feature, ornullif none.- Specified by:
getValuein 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 thisAssociationinstance, and conversely.- Overrides:
getValuesin classAbstractAssociation- Returns:
- the features in a live collection.
-
setValue
Sets the feature.- Specified by:
setValuein classAbstractAssociation- Parameters:
value- the new value, ornullfor removing all values from this association.- See Also:
-
setValues
Sets the feature values. All previous values are replaced by the given collection.- Overrides:
setValuesin 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:
clonein 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.
-