Package org.apache.sis.feature
Class AbstractAssociation
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
AssociationView,MultiValuedAssociation,SingletonAssociation
public abstract class AbstractAssociation
extends Field<AbstractFeature>
implements Cloneable, Serializable
An instance of an feature association role containing the associated feature.
AbstractAssociation can be instantiated by calls to DefaultAssociationRole.newInstance().
Limitations
- Multi-threading:
AbstractAssociationinstances 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.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final DefaultAssociationRoleInformation about the association.private static final longFor cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new association of the given role. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a copy of this association.static AbstractAssociationcreate(DefaultAssociationRole role) Creates a new association of the given role.(package private) static AbstractAssociationcreate(DefaultAssociationRole role, Object value) Creates a new association of the given role initialized to the given value.(package private) final voidensureValid(DefaultFeatureType base, DefaultFeatureType type) Ensures that storing a feature of the given type is valid for an association expecting the given base type.org.opengis.util.GenericNamegetName()Returns the name of this association as defined by its role.getRole()Returns information about the association.abstract AbstractFeaturegetValue()Returns the associated feature, ornullif none.Returns all features, or an empty collection if none.org.opengis.metadata.quality.DataQualityquality()Verifies if the current association value mets the constraints defined by the association role.abstract voidsetValue(AbstractFeature value) Sets the associated feature.voidsetValues(Collection<? extends AbstractFeature> values) Sets the features.toString()Returns a string representation of this association.Methods inherited from class org.apache.sis.feature.Field
isDeprecated, isSingleton
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
role
Information about the association.
-
-
Constructor Details
-
AbstractAssociation
Creates a new association of the given role.- Parameters:
role- information about the association.- See Also:
-
-
Method Details
-
create
Creates a new association of the given role.- Parameters:
role- information about the association.- Returns:
- the new association.
- See Also:
-
create
Creates a new association of the given role initialized to the given value.- Parameters:
role- information about the association.value- the initial value (may benull).- Returns:
- the new association.
-
getName
public org.opengis.util.GenericName getName()Returns the name of this association as defined by its role. This convenience method delegates toAbstractIdentifiedType.getName(). -
getRole
Returns information about the association.Warning: In a future SIS version, the return type may be changed toorg.opengis.feature.AssociationRole. This change is pending GeoAPI revision.- Returns:
- information about the association.
-
getValue
Returns the associated feature, ornullif none. This convenience method can be invoked in the common case where the maximum number of features is restricted to 1 or 0.Warning: In a future SIS version, the return type may be changed toorg.opengis.feature.Feature. This change is pending GeoAPI revision.- Specified by:
getValuein classField<AbstractFeature>- Returns:
- the associated 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.The default implementation returns a collection which will delegate its work to
getValue()andField.setValue(Object).- Overrides:
getValuesin classField<AbstractFeature>- Returns:
- the features in a live collection.
-
setValue
Sets the associated feature.Warning: In a future SIS version, the argument type may be changed toorg.opengis.feature.Feature. This change is pending GeoAPI revision.Validation
The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking thequality()method.- Specified by:
setValuein classField<AbstractFeature>- Parameters:
value- the new value, ornull.- Throws:
IllegalArgumentException- if the given feature is not valid for this association.- See Also:
-
setValues
Sets the features. All previous values are replaced by the given collection.The default implementation ensures that the given collection contains at most one element, then delegates to
setValue(AbstractFeature).- Overrides:
setValuesin classField<AbstractFeature>- Parameters:
values- the new values.- Throws:
IllegalArgumentException- if the given collection contains too many elements.
-
ensureValid
Ensures that storing a feature of the given type is valid for an association expecting the given base type. -
quality
public org.opengis.metadata.quality.DataQuality quality()Verifies if the current association value mets the constraints defined by the association role. This method returns at most one report with a result for each constraint violations found, if any. SeeAbstractAttribute.quality()for an example.This association is valid if this method does not report any conformance result having a pass value of
false.- Returns:
- reports on all constraint violations found.
- See Also:
-
toString
Returns a string representation of this association. The returned string is for debugging purpose and may change in any future SIS version. -
clone
Returns a copy of this association. The default implementation returns a shallow copy: the association value is not cloned. However, subclasses may choose to do otherwise.- Overrides:
clonein classObject- Returns:
- a clone of this association.
- Throws:
CloneNotSupportedException- if this association cannot be cloned. The default implementation never throw this exception. However, subclasses may throw it.
-