sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1677488 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation: DefaultConcatenatedOperation.java DefaultOperationMethod.java DefaultPassThroughOperation.java SubTypes.java
Date Sun, 03 May 2015 21:31:25 GMT
Author: desruisseaux
Date: Sun May  3 21:31:25 2015
New Revision: 1677488

URL: http://svn.apache.org/r1677488
Log:
Referencing: added missing "castOrCopy" methods.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1677488&r1=1677487&r2=1677488&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
[UTF-8] Sun May  3 21:31:25 2015
@@ -253,6 +253,39 @@ public class DefaultConcatenatedOperatio
     }
 
     /**
+     * Creates a new coordinate operation 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 operation The coordinate operation to copy.
+     *
+     * @see #castOrCopy(ConcatenatedOperation)
+     */
+    protected DefaultConcatenatedOperation(final ConcatenatedOperation operation) {
+        super(operation);
+        operations = operation.getOperations();
+    }
+
+    /**
+     * Returns a SIS coordinate operation implementation with the values of the given arbitrary
implementation.
+     * If the given object is already an instance of {@code DefaultConcatenatedOperation},
then it is returned
+     * unchanged. Otherwise a new {@code DefaultConcatenatedOperation} instance is created
using the
+     * {@linkplain #DefaultConcatenatedOperation(ConcatenatedOperation) copy constructor}
and returned.
+     * Note that this is a <cite>shallow</cite> copy operation, since the other
properties contained in the given
+     * object are not recursively copied.
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static DefaultConcatenatedOperation castOrCopy(final ConcatenatedOperation object)
{
+        return (object == null) || (object instanceof DefaultConcatenatedOperation)
+                ? (DefaultConcatenatedOperation) object : new DefaultConcatenatedOperation(object);
+    }
+
+    /**
      * Returns the GeoAPI interface implemented by this class.
      * The SIS implementation returns {@code ConcatenatedOperation.class}.
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1677488&r1=1677487&r2=1677488&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] Sun May  3 21:31:25 2015
@@ -276,7 +276,7 @@ public class DefaultOperationMethod exte
      *         or {@code null} if it is not going to have any declared authority.
      * @return The identified object properties in a mutable map.
      */
-    static Map<String,Object> getProperties(final IdentifiedObject info, final Citation
authority) {
+    private static Map<String,Object> getProperties(final IdentifiedObject info, final
Citation authority) {
         final Map<String,Object> properties = new HashMap<>(IdentifiedObjects.getProperties(info));
         properties.put(NAME_KEY, new NamedIdentifier(authority, info.getName().getCode()));
         properties.remove(IDENTIFIERS_KEY);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java?rev=1677488&r1=1677487&r2=1677488&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
[UTF-8] Sun May  3 21:31:25 2015
@@ -100,6 +100,39 @@ public class DefaultPassThroughOperation
     }
 
     /**
+     * Creates a new coordinate operation 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 operation The coordinate operation to copy.
+     *
+     * @see #castOrCopy(PassThroughOperation)
+     */
+    protected DefaultPassThroughOperation(final PassThroughOperation operation) {
+        super(operation);
+        this.operation = operation.getOperation();
+    }
+
+    /**
+     * Returns a SIS coordinate operation implementation with the values of the given arbitrary
implementation.
+     * If the given object is already an instance of {@code DefaultPassThroughOperation},
then it is returned
+     * unchanged. Otherwise a new {@code DefaultPassThroughOperation} instance is created
using the
+     * {@linkplain #DefaultPassThroughOperation(PassThroughOperation) copy constructor} and
returned.
+     * Note that this is a <cite>shallow</cite> copy operation, since the other
properties contained in the given
+     * object are not recursively copied.
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static DefaultPassThroughOperation castOrCopy(final PassThroughOperation object)
{
+        return (object == null) || (object instanceof DefaultPassThroughOperation)
+                ? (DefaultPassThroughOperation) object : new DefaultPassThroughOperation(object);
+    }
+
+    /**
      * Returns the GeoAPI interface implemented by this class.
      * The SIS implementation returns {@code PassThroughOperation.class}.
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java?rev=1677488&r1=1677487&r2=1677488&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
[UTF-8] Sun May  3 21:31:25 2015
@@ -57,6 +57,12 @@ final class SubTypes {
         if (object instanceof Conversion) {
             return forConversion((Conversion) object);
         }
+        if (object instanceof PassThroughOperation) {
+            return DefaultPassThroughOperation.castOrCopy((PassThroughOperation) object);
+        }
+        if (object instanceof ConcatenatedOperation) {
+            return DefaultConcatenatedOperation.castOrCopy((ConcatenatedOperation) object);
+        }
         if (object instanceof SingleOperation) {
             return (object instanceof AbstractSingleOperation) ? (AbstractSingleOperation)
object
                    : new AbstractSingleOperation((SingleOperation) object);



Mime
View raw message