sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1784310 - in /sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer: DefaultLocationType.java LocationTypeSnapshot.java ReferencingByIdentifiers.java
Date Fri, 24 Feb 2017 18:07:03 GMT
Author: desruisseaux
Date: Fri Feb 24 18:07:03 2017
New Revision: 1784310

URL: http://svn.apache.org/viewvc?rev=1784310&view=rev
Log:
Rename DefaultLocationType and LocationTypeSnapshot, make ReferenceByIdentifiers non-abstract.

Added:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationTypeSnapshot.java
      - copied, changed from r1784309, sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/DefaultLocationType.java
Removed:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/DefaultLocationType.java
Modified:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java

Copied: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationTypeSnapshot.java
(from r1784309, sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/DefaultLocationType.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationTypeSnapshot.java?p2=sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationTypeSnapshot.java&p1=sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/DefaultLocationType.java&r1=1784309&r2=1784310&rev=1784310&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/DefaultLocationType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationTypeSnapshot.java
[UTF-8] Fri Feb 24 18:07:03 2017
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.List;
 import java.util.Collection;
 import java.util.Collections;
+import java.io.Serializable;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Party;
 import org.opengis.metadata.extent.GeographicExtent;
@@ -31,14 +32,21 @@ import org.apache.sis.util.ArgumentCheck
 
 
 /**
- * Unmodifiable description of a location.
+ * Unmodifiable description of a location created as a snapshot of another {@link LocationType}
instance
+ * at {@link ReferencingByIdentifiers} construction time. This instance will be set a different
reference
+ * system than the original location type.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-final class DefaultLocationType implements LocationType {
+final class LocationTypeSnapshot implements LocationType, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 9032473745502779734L;
+
     /**
      * Name of the location type.
      */
@@ -89,11 +97,11 @@ final class DefaultLocationType implemen
      *
      * @param source    the location type to use as a template.
      * @param rs        the reference system that comprises this location type.
-     * @param existing  other {@code DefaultLocationType} instances created before this one.
+     * @param existing  other {@code LocationTypeSnapshot} instances created before this
one.
      */
     @SuppressWarnings("ThisEscapedInObjectConstruction")
-    private DefaultLocationType(final LocationType source, final ReferenceSystemUsingIdentifiers
rs,
-            final Map<LocationType, DefaultLocationType> existing)
+    private LocationTypeSnapshot(final LocationType source, final ReferenceSystemUsingIdentifiers
rs,
+            final Map<LocationType, LocationTypeSnapshot> existing)
     {
         /*
          * Put 'this' in the map at the beginning in case the parents and children contain
cyclic references.
@@ -121,15 +129,15 @@ final class DefaultLocationType implemen
      * @param existing  an initially empty identity hash map for internal usage by this method.
      */
     static List<LocationType> snapshot(final Collection<? extends LocationType>
types,
-            final ReferenceSystemUsingIdentifiers rs, final Map<LocationType, DefaultLocationType>
existing)
+            final ReferenceSystemUsingIdentifiers rs, final Map<LocationType, LocationTypeSnapshot>
existing)
     {
         final LocationType[] array = types.toArray(new LocationType[types.size()]);
         for (int i=0; i < array.length; i++) {
             final LocationType source = array[i];
             ArgumentChecks.ensureNonNullElement("types", i, source);
-            DefaultLocationType copy = existing.get(source);
+            LocationTypeSnapshot copy = existing.get(source);
             if (copy == null) {
-                copy = new DefaultLocationType(source, rs, existing);
+                copy = new LocationTypeSnapshot(source, rs, existing);
             }
             array[i] = copy;
         }

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java?rev=1784310&r1=1784309&r2=1784310&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
[UTF-8] Fri Feb 24 18:07:03 2017
@@ -50,7 +50,7 @@ import org.apache.sis.util.iso.Types;
  * @module
  */
 @XmlTransient
-public abstract class ReferencingByIdentifiers extends AbstractReferenceSystem implements
ReferenceSystemUsingIdentifiers {
+public class ReferencingByIdentifiers extends AbstractReferenceSystem implements ReferenceSystemUsingIdentifiers
{
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -150,7 +150,7 @@ public abstract class ReferencingByIdent
          * we invoke package-private method in such a way that if an exception is thrown,
the whole tree
          * (with all 'this' references) will be discarded.
          */
-        locationTypes = DefaultLocationType.snapshot(Arrays.asList(types), this, new IdentityHashMap<>());
+        locationTypes = LocationTypeSnapshot.snapshot(Arrays.asList(types), this, new IdentityHashMap<>());
     }
 
     /**
@@ -210,6 +210,7 @@ public abstract class ReferencingByIdent
      * @return {@code true} if both objects are equal.
      */
     @Override
+    @SuppressWarnings("fallthrough")
     public boolean equals(final Object object, final ComparisonMode mode) {
         if (!super.equals(object, mode)) {
             return false;
@@ -218,16 +219,22 @@ public abstract class ReferencingByIdent
             case STRICT: {
                 final ReferencingByIdentifiers that = (ReferencingByIdentifiers) object;
                 return Objects.equals(theme,        that.theme) &&
-                       Objects.equals(overallOwner, that.overallOwner);
+                       Objects.equals(overallOwner, that.overallOwner) &&
+                       locationTypes.equals(that.locationTypes);
             }
             case BY_CONTRACT: {
                 final ReferenceSystemUsingIdentifiers that = (ReferenceSystemUsingIdentifiers)
object;
-                return Utilities.deepEquals(getTheme(),        that.getTheme(),        mode)
&&
-                       Utilities.deepEquals(getOverallOwner(), that.getOverallOwner(), mode);
+                if (!Utilities.deepEquals(getTheme(),        that.getTheme(),        mode)
||
+                    !Utilities.deepEquals(getOverallOwner(), that.getOverallOwner(), mode))
+                {
+                    return false;
+                }
+                // Fall through
             }
             default: {
                 // Theme and owner are metadata, so they can be ignored.
-                return true;
+                return Utilities.deepEquals(getLocationTypes(),
+                        ((ReferenceSystemUsingIdentifiers) object).getLocationTypes(), mode);
             }
         }
     }
@@ -241,6 +248,6 @@ public abstract class ReferencingByIdent
      */
     @Override
     protected long computeHashCode() {
-        return super.computeHashCode() + Objects.hash(theme, overallOwner);
+        return super.computeHashCode() + Objects.hash(theme, overallOwner, locationTypes);
     }
 }



Mime
View raw message