Class AbstractLocationType

java.lang.Object
org.apache.sis.referencing.gazetteer.AbstractLocationType
All Implemented Interfaces:
LenientComparable
Direct Known Subclasses:
FinalLocationType, ModifiableLocationType

abstract class AbstractLocationType extends Object implements LenientComparable
Default implementation of toString(), equals(Object) and hashCode() methods for LocationType implementations.
Since:
0.8
Version:
0.8
  • Constructor Details

    • AbstractLocationType

      protected AbstractLocationType()
      For sub-class constructors.
  • Method Details

    • snapshot

      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, or null if 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 of checkForCycles() 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

      public abstract Collection<? extends org.opengis.util.InternationalString> 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

      public abstract ReferencingByIdentifiers getReferenceSystem()
      The reference system that comprises this location type.
    • getOwner

      public abstract AbstractParty getOwner()
      Name of organization or class of organization able to create and destroy location instances.
    • getParents

      public abstract Collection<? extends AbstractLocationType> 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

      public abstract Collection<? extends AbstractLocationType> getChildren()
      Child location types (location types which sub-divides this location type).
    • equals

      public boolean equals(Object object, ComparisonMode mode)
      Compares this location type with the specified object for equality. This method compares the value of getName() and getChildren() in all modes. At the opposite, values of getParents() and getReferenceSystem() are never compared, no matter the mode, for avoiding never-ending loops. Other properties may or may not be compared depending on the mode argument.

      If the mode argument value is STRICT or BY_CONTRACT, then almost all properties are compared including the theme and the owner.

      Specified by:
      equals in interface LenientComparable
      Parameters:
      object - the object to compare to this.
      mode - STRICT for performing a strict comparison, or IGNORE_METADATA for comparing only properties relevant to location identifications.
      Returns:
      true if both objects are equal.
      See Also:
    • equals

      public final boolean equals(Object object)
      Compares this location type with the specified object for strict equality. This method compares all properties except the value returned by getParents() and getReferenceSystem(), for avoiding never-ending loops.

      This method is implemented as below:

      Specified by:
      equals in interface LenientComparable
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare to this.
      Returns:
      true if both objects are equal.
      See Also:
    • hashCode

      public int hashCode()
      Returns a hash code value for this location type.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this location type.
    • toString

      public String 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.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this location type.
    • format

      private static void format(AbstractLocationType type, TreeTable.Node node)
      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 to checkForCycles().