sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1554894 - in /sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing: ./ cs/ datum/
Date Thu, 02 Jan 2014 20:13:56 GMT
Author: desruisseaux
Date: Thu Jan  2 20:13:55 2014
New Revision: 1554894

URL: http://svn.apache.org/r1554894
Log:
More reliable comparison of geodetic objects, which need to check more carefully about their type.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -46,6 +46,7 @@ import org.apache.sis.xml.Namespaces;
 import org.apache.sis.util.Deprecable;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.LenientComparable;
+import org.apache.sis.util.Classes;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.resources.Errors;
 
@@ -351,6 +352,29 @@ public class AbstractIdentifiedObject ex
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * This information is part of the data compared by {@link #equals(Object, ComparisonMode)}.
+     *
+     * <p>The default implementation returns {@code IdentifiedObject.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.</p>
+     *
+     * {@section Invariants}
+     * The following invariants must hold for all {@code AbstractIdentifiedObject} instances:
+     * <ul>
+     *   <li><code>getInterface().{@linkplain Class#isInstance(Object) isInstance}(this)</code>
+     *       shall return {@code true}.</li>
+     *   <li>If {@code A.getClass() == B.getClass()} is {@code true}, then
+     *       {@code A.getInterface() == B.getInterface()} shall be {@code true}.
+     *       Note that the converse does not need to hold.</li>
+     * </ul>
+     *
+     * @return The GeoAPI interface implemented by this class.
+     */
+    public Class<? extends IdentifiedObject> getInterface() {
+        return IdentifiedObject.class;
+    }
+
+    /**
      * The {@code gml:id}, which is mandatory. The current implementation searches for the first identifier,
      * regardless its authority. If no identifier is found, then the name is used.
      * If no name is found (which should not occur for valid objects), then this method returns {@code null}.
@@ -618,13 +642,17 @@ public class AbstractIdentifiedObject ex
      * The strictness level is controlled by the second argument:
      *
      * <ul>
-     *   <li>If {@code mode} is {@link ComparisonMode#STRICT STRICT}, then all available properties
-     *       are compared including {@linkplain #getName() name}, {@linkplain #getRemarks() remarks},
-     *       {@linkplain #getIdentifiers() identifiers code}, <i>etc.</i></li>
+     *   <li>If {@code mode} is {@link ComparisonMode#STRICT STRICT}, then this method verifies if the two
+     *       objects are of the same {@linkplain #getClass() class} and compares all public properties,
+     *       including SIS-specific (non standard) properties.</li>
+     *   <li>If {@code mode} is {@link ComparisonMode#BY_CONTRACT}, then this method verifies if the the two
+     *       object implements the same {@linkplain #getInterface() GeoAPI interface} and compares all properties
+     *       defined by that interface ({@linkplain #getName() name}, {@linkplain #getRemarks() remarks},
+     *       {@linkplain #getIdentifiers() identifiers}, <i>etc</i>).</li>
      *   <li>If {@code mode} is {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA},
      *       then this method compares only the properties needed for computing transformations.
      *       In other words, {@code sourceCRS.equals(targetCRS, IGNORE_METADATA)} returns {@code true}
-     *       if the transformation from {@code sourceCRS} to {@code targetCRS} is likely to be the
+     *       if the transformation from {@code sourceCRS} to {@code targetCRS} would be the
      *       identity transform, no matter what {@link #getName()} said.</li>
      * </ul>
      *
@@ -640,9 +668,7 @@ public class AbstractIdentifiedObject ex
      * See {@link #isHeuristicMatchForName(String)} for more information.
      *
      * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
+     * @param  mode The strictness level of the comparison.
      * @return {@code true} if both objects are equal.
      *
      * @see #computeHashCode()
@@ -679,7 +705,7 @@ public class AbstractIdentifiedObject ex
                        Objects.equals(remarks, that.remarks);
             }
             case BY_CONTRACT: {
-                if (!(object instanceof IdentifiedObject)) {
+                if (!implementsSameInterface(object)) {
                     return false;
                 }
                 final IdentifiedObject that = (IdentifiedObject) object;
@@ -691,7 +717,7 @@ public class AbstractIdentifiedObject ex
             case IGNORE_METADATA:
             case APPROXIMATIVE:
             case DEBUG: {
-                return (object instanceof IdentifiedObject);
+                return implementsSameInterface(object);
             }
             default: {
                 throw new IllegalArgumentException(Errors.format(Errors.Keys.UnknownEnumValue_1, mode));
@@ -700,6 +726,26 @@ public class AbstractIdentifiedObject ex
     }
 
     /**
+     * Returns {@code true} if the given object implements the same GeoAPI interface than this object.
+     */
+    private boolean implementsSameInterface(final Object object) {
+        final Class<? extends IdentifiedObject> type = getInterface();
+        if (object instanceof AbstractIdentifiedObject) {
+            return ((AbstractIdentifiedObject) object).getInterface() == type;
+        }
+        /*
+         * Fallback for non-SIS implementations.
+         */
+        if (type.isInstance(object)) {
+            final Class<? extends IdentifiedObject>[] t = Classes.getLeafInterfaces(object.getClass(), type);
+            if (t.length == 1 && t[0] == type) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Compares the specified object with this object for equality.
      * This method is implemented as below (omitting assertions):
      *
@@ -751,7 +797,8 @@ public class AbstractIdentifiedObject ex
      * Invoked by {@link #hashCode()} for computing the hash code when first needed.
      * This method is invoked at most once in normal execution, or an arbitrary amount of times if Java
      * assertions are enabled. The hash code value shall never change during the whole lifetime of this
-     * object.
+     * object in a JVM. The hash code value does not need to be the same in two different executions of
+     * the JVM.
      *
      * {@section Overriding}
      * Subclasses can override this method for using more properties in hash code calculation.
@@ -768,6 +815,6 @@ public class AbstractIdentifiedObject ex
      * @return The hash code value. This value may change in any future Apache SIS version.
      */
     protected long computeHashCode() {
-        return Objects.hash(name, nonNull(alias), nonNull(identifiers), remarks) ^ serialVersionUID;
+        return Objects.hash(name, nonNull(alias), nonNull(identifiers), remarks) ^ getInterface().hashCode();
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -93,21 +93,6 @@ public class AbstractReferenceSystem ext
     }
 
     /**
-     * Constructs a new reference system with the same values than the specified one.
-     * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
-     * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
-     *
-     * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
-     *
-     * @param object The reference system to copy.
-     */
-    public AbstractReferenceSystem(final ReferenceSystem object) {
-        super(object);
-        domainOfValidity = object.getDomainOfValidity();
-        scope            = object.getScope();
-    }
-
-    /**
      * Constructs a reference system from the given properties.
      * The properties given in argument follow the same rules than for the
      * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
@@ -163,6 +148,33 @@ public class AbstractReferenceSystem ext
     }
 
     /**
+     * Constructs a new reference system with the same values than the specified one.
+     * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
+     * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
+     *
+     * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+     *
+     * @param object The reference system to copy.
+     */
+    protected AbstractReferenceSystem(final ReferenceSystem object) {
+        super(object);
+        domainOfValidity = object.getDomainOfValidity();
+        scope            = object.getScope();
+    }
+
+    /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code ReferenceSystem.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
+     *
+     * @return The GeoAPI interface implemented by this class.
+     */
+    @Override
+    public Class<? extends ReferenceSystem> getInterface() {
+        return ReferenceSystem.class;
+    }
+
+    /**
      * Returns the region or timeframe in which this reference system is valid,
      * or {@code null} if unspecified.
      *
@@ -201,7 +213,7 @@ public class AbstractReferenceSystem ext
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
-        if (!(object instanceof ReferenceSystem && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -231,10 +243,6 @@ public class AbstractReferenceSystem ext
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this ReferenceSystem implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + Objects.hash(domainOfValidity, scope));
+        return super.computeHashCode() + Objects.hash(domainOfValidity, scope);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -228,6 +228,18 @@ public class AbstractCS extends Abstract
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code CoordinateSystem.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
+     *
+     * @return The coordinate system interface implemented by this class.
+     */
+    @Override
+    public Class<? extends CoordinateSystem> getInterface() {
+        return CoordinateSystem.class;
+    }
+
+    /**
      * Returns the number of dimensions of this coordinate system.
      * This is the number of axes given at construction time.
      *
@@ -261,6 +273,9 @@ public class AbstractCS extends Abstract
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
+        if (object == this) {
+            return true; // Slight optimization.
+        }
         if (!super.equals(object, mode)) {
             return false;
         }
@@ -270,9 +285,6 @@ public class AbstractCS extends Abstract
                 return Arrays.equals(axes, ((AbstractCS) object).axes);
             }
             default: {
-                if (!(object instanceof CoordinateSystem)) {
-                    return false;
-                }
                 final CoordinateSystem that = (CoordinateSystem) object;
                 final int dimension = getDimension();
                 if (dimension != that.getDimension()) {
@@ -297,11 +309,7 @@ public class AbstractCS extends Abstract
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this CoordinateSystem implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + Arrays.hashCode(axes));
+        return super.computeHashCode() + Arrays.hashCode(axes);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -24,7 +24,6 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -195,19 +194,14 @@ public class DefaultAffineCS extends Abs
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code AffineCS.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * @return The affine coordinate system interface implemented by this class.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof AffineCS) && super.equals(object, mode);
+    public Class<? extends AffineCS> getInterface() {
+        return AffineCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -22,7 +22,6 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -201,19 +200,17 @@ public class DefaultCartesianCS extends 
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code CartesianCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>CartesianCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code CartesianCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof CartesianCS) && super.equals(object, mode);
+    public Class<? extends CartesianCS> getInterface() {
+        return CartesianCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -186,9 +186,6 @@ public class DefaultCompoundCS extends A
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
         if (!(object instanceof DefaultCompoundCS && super.equals(object, mode))) {
             return false;
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -339,6 +339,21 @@ public class DefaultCoordinateSystemAxis
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code CoordinateSystemAxis.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>CoordinateSystemAxis</code> sub-interface. Overriding possibility is left mostly
+     *        for implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code CoordinateSystemAxis.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends CoordinateSystemAxis> getInterface() {
+        return CoordinateSystemAxis.class;
+    }
+
+    /**
      * Returns the direction of this coordinate system axis.
      * This direction is often approximate and intended to provide a human interpretable meaning to the axis.
      * A {@linkplain AbstractCS coordinate system} can not contain two axes having the same direction or
@@ -551,7 +566,7 @@ public class DefaultCoordinateSystemAxis
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof CoordinateSystemAxis && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         final DefaultCoordinateSystemAxis that = castOrCopy((CoordinateSystemAxis) object);
@@ -636,12 +651,8 @@ public class DefaultCoordinateSystemAxis
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this CoordinateSystemAxis implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + Objects.hashCode(unit) + Objects.hashCode(direction)
-                + Double.doubleToLongBits(minimumValue) + 31*Double.doubleToLongBits(maximumValue));
+        return super.computeHashCode() + Objects.hashCode(unit) + Objects.hashCode(direction)
+                + Double.doubleToLongBits(minimumValue) + 31*Double.doubleToLongBits(maximumValue);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -22,7 +22,6 @@ import org.opengis.referencing.cs.Cylind
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.measure.Units;
 
 
@@ -162,19 +161,17 @@ public class DefaultCylindricalCS extend
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code CylindricalCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>CylindricalCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code CylindricalCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof CylindricalCS) && super.equals(object, mode);
+    public Class<? extends CylindricalCS> getInterface() {
+        return CylindricalCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -24,7 +24,6 @@ import org.opengis.referencing.cs.Ellips
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.measure.Units;
 
 
@@ -186,19 +185,17 @@ public class DefaultEllipsoidalCS extend
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code EllipsoidalCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>EllipsoidalCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code EllipsoidalCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof EllipsoidalCS) && super.equals(object, mode);
+    public Class<? extends EllipsoidalCS> getInterface() {
+        return EllipsoidalCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -23,7 +23,6 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -155,19 +154,17 @@ public class DefaultLinearCS extends Abs
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code LinearCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>LinearCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code LinearCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof LinearCS) && super.equals(object, mode);
+    public Class<? extends LinearCS> getInterface() {
+        return LinearCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -23,7 +23,6 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -158,19 +157,17 @@ public class DefaultPolarCS extends Abst
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code PolarCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>PolarCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code PolarCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof PolarCS) && super.equals(object, mode);
+    public Class<? extends PolarCS> getInterface() {
+        return PolarCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -22,7 +22,6 @@ import org.opengis.referencing.cs.Spheri
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.measure.Units;
 
 
@@ -162,19 +161,17 @@ public class DefaultSphericalCS extends 
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code SphericalCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>SphericalCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code SphericalCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof SphericalCS) && super.equals(object, mode);
+    public Class<? extends SphericalCS> getInterface() {
+        return SphericalCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -23,7 +23,6 @@ import org.opengis.referencing.cs.TimeCS
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.measure.Units;
 
 
@@ -152,19 +151,17 @@ public class DefaultTimeCS extends Abstr
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code TimeCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>TimeCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code TimeCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof TimeCS) && super.equals(object, mode);
+    public Class<? extends TimeCS> getInterface() {
+        return TimeCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.cs;
 import java.util.Map;
 import org.opengis.referencing.cs.UserDefinedCS;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -144,19 +143,17 @@ public class DefaultUserDefinedCS extend
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code UserDefinedCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>UserDefinedCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code UserDefinedCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof UserDefinedCS) && super.equals(object, mode);
+    public Class<? extends UserDefinedCS> getInterface() {
+        return UserDefinedCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -22,7 +22,6 @@ import org.opengis.referencing.cs.Vertic
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -164,19 +163,17 @@ public class DefaultVerticalCS extends A
     }
 
     /**
-     * Compares this coordinate system with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code VerticalCS.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>VerticalCS</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code VerticalCS.class} or a user-defined sub-interface.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof VerticalCS) && super.equals(object, mode);
+    public Class<? extends VerticalCS> getInterface() {
+        return VerticalCS.class;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -242,6 +242,18 @@ public class AbstractDatum extends Abstr
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code Datum.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
+     *
+     * @return The datum interface implemented by this class.
+     */
+    @Override
+    public Class<? extends Datum> getInterface() {
+        return Datum.class;
+    }
+
+    /**
      * Returns a description of the point(s) used to anchor the datum to the Earth.
      * Also known as the "origin", especially for Engineering and Image Datums.
      *
@@ -371,7 +383,7 @@ public class AbstractDatum extends Abstr
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
-        if (!(object instanceof Datum && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -412,12 +424,7 @@ public class AbstractDatum extends Abstr
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this Datum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() +
-                Objects.hash(anchorPoint, realizationEpoch, domainOfValidity, scope));
+        return super.computeHashCode() + Objects.hash(anchorPoint, realizationEpoch, domainOfValidity, scope);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -370,6 +370,21 @@ public class DefaultEllipsoid extends Ab
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code Ellipsoid.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>Ellipsoid</code> sub-interface. This method may be overridden if an implementor
+     *        extended GeoAPI with his own set of interfaces.}
+     *
+     * @return {@code Ellipsoid.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends Ellipsoid> getInterface() {
+        return Ellipsoid.class;
+    }
+
+    /**
      * Returns the linear unit of the {@linkplain #getSemiMajorAxis() semi-major}
      * and {@linkplain #getSemiMinorAxis() semi-minor} axis values.
      *
@@ -691,7 +706,7 @@ public class DefaultEllipsoid extends Ab
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof Ellipsoid && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -732,12 +747,8 @@ public class DefaultEllipsoid extends Ab
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this Ellipsoid implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + Double.doubleToLongBits(semiMajorAxis) +
-               31 * Double.doubleToLongBits(ivfDefinitive ? inverseFlattening : semiMinorAxis));
+        return super.computeHashCode() + Double.doubleToLongBits(semiMajorAxis) +
+               31 * Double.doubleToLongBits(ivfDefinitive ? inverseFlattening : semiMinorAxis);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -23,7 +23,6 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.referencing.datum.EngineeringDatum;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.io.wkt.Formatter;
 
 
@@ -149,36 +148,18 @@ public class DefaultEngineeringDatum ext
     }
 
     /**
-     * Compares this datum with the specified object for equality.
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code EngineeringDatum.class}.
      *
-     * @param  object The object to compare to {@code this}.
-     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
-     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
-     *         relevant to coordinate transformations.
-     * @return {@code true} if both objects are equal.
-     */
-    @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
-        return (object instanceof EngineeringDatum) && super.equals(object, mode);
-    }
-
-    /**
-     * Invoked by {@link #hashCode()} for computing the hash code when first needed.
-     * See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
-     * for more information.
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>EngineeringDatum</code> sub-interface. Overriding possibility is left mostly
+     *        for implementors who wish to extend GeoAPI with their own set of interfaces.}
      *
-     * @return The hash code value. This value may change in any future Apache SIS version.
+     * @return {@code EngineeringDatum.class} or a user-defined sub-interface.
      */
     @Override
-    protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this EngineeringDatum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ super.computeHashCode();
+    public Class<? extends EngineeringDatum> getInterface() {
+        return EngineeringDatum.class;
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -291,6 +291,21 @@ public class DefaultGeodeticDatum extend
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code GeodeticDatum.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>GeodeticDatum</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code GeodeticDatum.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends GeodeticDatum> getInterface() {
+        return GeodeticDatum.class;
+    }
+
+    /**
      * Returns the ellipsoid given at construction time.
      *
      * @return The ellipsoid.
@@ -441,7 +456,7 @@ public class DefaultGeodeticDatum extend
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof GeodeticDatum && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -478,12 +493,7 @@ public class DefaultGeodeticDatum extend
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this GeodeticDatum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() +
-                Objects.hashCode(ellipsoid) + 31 * Objects.hashCode(primeMeridian));
+        return super.computeHashCode() + Objects.hashCode(ellipsoid) + 31 * Objects.hashCode(primeMeridian);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -166,6 +166,21 @@ public class DefaultImageDatum extends A
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code ImageDatum.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>ImageDatum</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code ImageDatum.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends ImageDatum> getInterface() {
+        return ImageDatum.class;
+    }
+
+    /**
      * Specification of the way the image grid is associated with the image data attributes.
      *
      * @return The way image grid is associated with image data attributes.
@@ -189,7 +204,7 @@ public class DefaultImageDatum extends A
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof ImageDatum && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -211,11 +226,7 @@ public class DefaultImageDatum extends A
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this ImageDatum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + Objects.hashCode(pixelInCell));
+        return super.computeHashCode() + Objects.hashCode(pixelInCell);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -194,6 +194,21 @@ public class DefaultPrimeMeridian extend
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code PrimeMeridian.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>PrimeMeridian</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code PrimeMeridian.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends PrimeMeridian> getInterface() {
+        return PrimeMeridian.class;
+    }
+
+    /**
      * Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.
      *
      * @return The prime meridian Greenwich longitude, in {@linkplain #getAngularUnit() angular unit}.
@@ -271,7 +286,7 @@ public class DefaultPrimeMeridian extend
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof PrimeMeridian && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -307,12 +322,7 @@ public class DefaultPrimeMeridian extend
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this PrimeMeridian implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() +
-                Double.doubleToLongBits(greenwichLongitude) + Objects.hashCode(angularUnit));
+        return super.computeHashCode() + Double.doubleToLongBits(greenwichLongitude) + Objects.hashCode(angularUnit);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java Thu Jan  2 20:13:55 2014
@@ -194,6 +194,21 @@ public class DefaultTemporalDatum extend
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code TemporalDatum.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>TemporalDatum</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code TemporalDatum.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends TemporalDatum> getInterface() {
+        return TemporalDatum.class;
+    }
+
+    /**
      * Returns the date and time origin of this temporal datum.
      *
      * @return The date and time origin of this temporal datum.
@@ -226,7 +241,7 @@ public class DefaultTemporalDatum extend
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof TemporalDatum && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -240,7 +255,6 @@ public class DefaultTemporalDatum extend
     }
 
     /**
-    /**
      * Invoked by {@link #hashCode()} for computing the hash code when first needed.
      * See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
      * for more information.
@@ -249,10 +263,6 @@ public class DefaultTemporalDatum extend
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this TemporalDatum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + origin);
+        return super.computeHashCode() + origin;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1554894&r1=1554893&r2=1554894&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Thu Jan  2 20:13:55 2014
@@ -194,6 +194,21 @@ public class DefaultVerticalDatum extend
     }
 
     /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The SIS implementation returns {@code VerticalDatum.class}.
+     *
+     * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+     *        <code>VerticalDatum</code> sub-interface. Overriding possibility is left mostly for
+     *        implementors who wish to extend GeoAPI with their own set of interfaces.}
+     *
+     * @return {@code VerticalDatum.class} or a user-defined sub-interface.
+     */
+    @Override
+    public Class<? extends VerticalDatum> getInterface() {
+        return VerticalDatum.class;
+    }
+
+    /**
      * Returns the type of this datum, or infers the type from the datum name if no type were specified.
      * The later case occurs after unmarshalling, since GML 3.2 does not contain any attribute for the datum type.
      * It may also happen if the datum were created using reflection.
@@ -265,7 +280,7 @@ public class DefaultVerticalDatum extend
         if (object == this) {
             return true; // Slight optimization.
         }
-        if (!(object instanceof VerticalDatum && super.equals(object, mode))) {
+        if (!super.equals(object, mode)) {
             return false;
         }
         switch (mode) {
@@ -287,11 +302,7 @@ public class DefaultVerticalDatum extend
      */
     @Override
     protected long computeHashCode() {
-        /*
-         * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
-         * differentiate this VerticalDatum implementation from implementations of other GeoAPI interfaces.
-         */
-        return serialVersionUID ^ (super.computeHashCode() + type().hashCode());
+        return super.computeHashCode() + type().hashCode();
     }
 
     /**



Mime
View raw message