Class AbstractLocationType
java.lang.Object
org.apache.sis.referencing.gazetteer.AbstractLocationType
- All Implemented Interfaces:
LenientComparable
- Direct Known Subclasses:
FinalLocationType,ModifiableLocationType
Default implementation of
toString(), equals(Object) and hashCode() methods
for LocationType implementations.- Since:
- 0.8
- Version:
- 0.8
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final voidVerifies that there is not cycles in the children.private static voidcheckForCycles(AbstractLocationType type, Map<AbstractLocationType, Boolean> parents) Implementation ofcheckForCycles()to be invoked recursively for each children.final booleanCompares this location type with the specified object for strict equality.booleanequals(Object object, ComparisonMode mode) Compares this location type with the specified object for equality.private static voidformat(AbstractLocationType type, TreeTable.Node node) Invoked recursively for formatting the given type in the given tree.abstract Collection<? extends AbstractLocationType>Child location types (location types which sub-divides this location type).abstract org.opengis.util.InternationalStringThe way in which location instances are defined.abstract Collection<? extends org.opengis.util.InternationalString>Method(s) of uniquely identifying location instances.abstract org.opengis.util.InternationalStringgetName()Name of the location type.abstract AbstractPartygetOwner()Name of organization or class of organization able to create and destroy location instances.abstract Collection<? extends AbstractLocationType>Parent location types (location types of which this location type is a sub-division).abstract ReferencingByIdentifiersThe reference system that comprises this location type.abstract org.opengis.metadata.extent.GeographicExtentGeographic area within which the location type occurs.abstract org.opengis.util.InternationalStringgetTheme()Property used as the defining characteristic of the location type.inthashCode()Returns a hash code value for this location type.static List<AbstractLocationType>snapshot(ReferencingByIdentifiers rs, AbstractLocationType... types) Creates unmodifiable snapshots of the given location types.toString()Returns a string representation of this location type and all its children.
-
Constructor Details
-
AbstractLocationType
protected AbstractLocationType()For sub-class constructors.
-
-
Method Details
-
snapshot
public static List<AbstractLocationType> snapshot(ReferencingByIdentifiers rs, AbstractLocationType... types) Creates unmodifiable snapshots of the given location types. This method returns a new collection within which all elements are snapshots of the given location types (in iteration order), except the reference system which is set to the given value.The location types returned by this method are serializable if all properties (name, territory of use, etc. are also serializable).
- Parameters:
rs- the reference system to assign to the new location types, ornullif none.types- the location types for which to take a snapshot.- Returns:
- unmodifiable copies of the given location types.
-
checkForCycles
private static void checkForCycles(AbstractLocationType type, Map<AbstractLocationType, Boolean> parents) Implementation ofcheckForCycles()to be invoked recursively for each children.- Throws:
IllegalArgumentException- if an infinite recursivity is detected.
-
checkForCycles
final void checkForCycles()Verifies that there is not cycles in the children. This method should be invoked for validating a user argument.- Throws:
IllegalArgumentException- if an infinite recursivity is detected.
-
getName
public abstract org.opengis.util.InternationalString getName()Name of the location type. -
getTheme
public abstract org.opengis.util.InternationalString getTheme()Property used as the defining characteristic of the location type. -
getIdentifications
Method(s) of uniquely identifying location instances. -
getDefinition
public abstract org.opengis.util.InternationalString getDefinition()The way in which location instances are defined. -
getTerritoryOfUse
public abstract org.opengis.metadata.extent.GeographicExtent getTerritoryOfUse()Geographic area within which the location type occurs. -
getReferenceSystem
The reference system that comprises this location type. -
getOwner
Name of organization or class of organization able to create and destroy location instances. -
getParents
Parent location types (location types of which this location type is a sub-division). A location type can have more than one possible parent. For example the parent of a location type named “street” could be “locality”, “town” or “administrative area”. -
getChildren
Child location types (location types which sub-divides this location type). -
equals
Compares this location type with the specified object for equality. This method compares the value ofgetName()andgetChildren()in all modes. At the opposite, values ofgetParents()andgetReferenceSystem()are never compared, no matter the mode, for avoiding never-ending loops. Other properties may or may not be compared depending on themodeargument.If the
modeargument value isSTRICTorBY_CONTRACT, then almost all properties are compared including the theme and the owner.- Specified by:
equalsin interfaceLenientComparable- Parameters:
object- the object to compare tothis.mode-STRICTfor performing a strict comparison, orIGNORE_METADATAfor comparing only properties relevant to location identifications.- Returns:
trueif both objects are equal.- See Also:
-
equals
Compares this location type with the specified object for strict equality. This method compares all properties except the value returned bygetParents()andgetReferenceSystem(), for avoiding never-ending loops.This method is implemented as below:
- Specified by:
equalsin interfaceLenientComparable- Overrides:
equalsin classObject- Parameters:
object- the object to compare tothis.- Returns:
trueif both objects are equal.- See Also:
-
hashCode
public int hashCode()Returns a hash code value for this location type. -
toString
Returns a string representation of this location type and all its children. Current implementation formats a tree with the name and definition of each type, like below: The string representation is mostly for debugging purpose and may change in any future SIS version. -
format
Invoked recursively for formatting the given type in the given tree. This method does not perform any check against infinite recursivity on the assumption that subclasses verified this constraint by calls tocheckForCycles().
-