sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1626629 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/parameter/ test/java/org/apache/sis/parameter/
Date Sun, 21 Sep 2014 20:33:50 GMT
Author: desruisseaux
Date: Sun Sep 21 20:33:50 2014
New Revision: 1626629

URL: http://svn.apache.org/r1626629
Log:
DefaultParameterDescriptorGroup.getDirection() infers the value from the parameters that it
contains.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java?rev=1626629&r1=1626628&r2=1626629&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
[UTF-8] Sun Sep 21 20:33:50 2014
@@ -331,18 +331,6 @@ public class DefaultParameterDescriptor<
     }
 
     /**
-     * Creates a new parameter value instance initialized with the {@linkplain #getDefaultValue()
default value}.
-     * The {@linkplain DefaultParameterDescriptor parameter descriptor} for the created parameter
value will be
-     * {@code this} object.
-     *
-     * @return A parameter initialized to the default value.
-     */
-    @Override
-    public ParameterValue<T> createValue() {
-        return new DefaultParameterValue<>(this);
-    }
-
-    /**
      * Returns the class that describe the type of the parameter.
      *
      * @return The parameter value class.
@@ -455,6 +443,18 @@ public class DefaultParameterDescriptor<
     }
 
     /**
+     * Creates a new parameter value instance initialized with the {@linkplain #getDefaultValue()
default value}.
+     * The {@linkplain DefaultParameterDescriptor parameter descriptor} for the created parameter
value will be
+     * {@code this} object.
+     *
+     * @return A parameter initialized to the default value.
+     */
+    @Override
+    public ParameterValue<T> createValue() {
+        return new DefaultParameterValue<>(this);
+    }
+
+    /**
      * Compares the specified object with this parameter for equality.
      * The strictness level is controlled by the second argument.
      * This method compares the following properties in every cases:

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1626629&r1=1626628&r2=1626629&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] Sun Sep 21 20:33:50 2014
@@ -21,6 +21,7 @@ import java.util.Set;
 import java.util.List;
 import java.util.HashSet;
 import java.util.Collections;
+import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
@@ -263,16 +264,28 @@ public class DefaultParameterDescriptorG
     }
 
     /**
-     * Creates a new instance of {@linkplain DefaultParameterValueGroup parameter value group}
-     * initialized with the {@linkplain DefaultParameterDescriptor#getDefaultValue default
values}.
-     * The {@linkplain DefaultParameterValueGroup#getDescriptor() parameter descriptor} for
the
-     * created group will be {@code this} object.
+     * Returns an indication if all parameters in this group are inputs to the service, outputs
or both.
+     * If this group contains parameters with different direction, then this method returns
{@code null}.
      *
-     * @return A new parameter instance initialized to the default value.
+     * @return Indication if all parameters are inputs or outputs to the service, or {@code
null} if undetermined.
      */
     @Override
-    public ParameterValueGroup createValue() {
-        return new DefaultParameterValueGroup(this);
+    public ParameterDirection getDirection() {
+        ParameterDirection dir = null;
+        for (final GeneralParameterDescriptor param : descriptors) {
+            final ParameterDirection c = param.getDirection();
+            if (c == null) {
+                return null;
+            }
+            if (c != dir) {
+                if (dir == null) {
+                    dir = c;
+                } else {
+                    return null;
+                }
+            }
+        }
+        return dir;
     }
 
     /**
@@ -323,6 +336,19 @@ public class DefaultParameterDescriptorG
     }
 
     /**
+     * Creates a new instance of {@linkplain DefaultParameterValueGroup parameter value group}
+     * initialized with the {@linkplain DefaultParameterDescriptor#getDefaultValue default
values}.
+     * The {@linkplain DefaultParameterValueGroup#getDescriptor() parameter descriptor} for
the
+     * created group will be {@code this} object.
+     *
+     * @return A new parameter instance initialized to the default value.
+     */
+    @Override
+    public ParameterValueGroup createValue() {
+        return new DefaultParameterValueGroup(this);
+    }
+
+    /**
      * Compares the specified object with this parameter group for equality.
      *
      * @return {@inheritDoc}

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1626629&r1=1626628&r2=1626629&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] Sun Sep 21 20:33:50 2014
@@ -19,6 +19,7 @@ package org.apache.sis.parameter;
 import java.util.Map;
 import java.util.List;
 import java.util.HashMap;
+import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.test.DependsOn;
@@ -37,7 +38,7 @@ import static org.opengis.referencing.Id
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.4 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @DependsOn(DefaultParameterDescriptorTest.class)
@@ -95,6 +96,7 @@ public final strictfp class DefaultParam
      */
     @Test
     public void validateTestObjects() {
+        assertEquals(ParameterDirection.IN, M1_M1_O1_O2.getDirection());
         for (final GeneralParameterDescriptor descriptor : M1_M1_O1_O2.descriptors()) {
             AssertionError error = null;
             try {



Mime
View raw message