sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1625166 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/parameter/ test/java/org/apache/sis/parameter/
Date Mon, 15 Sep 2014 21:22:27 GMT
Author: desruisseaux
Date: Mon Sep 15 21:22:26 2014
New Revision: 1625166

URL: http://svn.apache.org/r1625166
Log:
Complete AbstractParameterDescriptor with code that moved from subclasses.

Removed:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MultiOccurrenceDescriptor.java
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
    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/main/java/org/apache/sis/parameter/ParameterBuilder.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -17,32 +17,217 @@
 package org.apache.sis.parameter;
 
 import java.util.Map;
+import javax.measure.unit.Unit;
 import org.opengis.util.InternationalString;
 import org.opengis.parameter.ParameterDirection;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
+import org.apache.sis.io.wkt.FormattableObject;
+import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.iso.Types;
+import org.apache.sis.util.Debug;
+
+import static org.apache.sis.util.Utilities.deepEquals;
+
+// Branch-dependent imports
+import java.util.Objects;
 
 
 /**
- * Base class of parameter descriptors.
+ * Abstract definition of a parameter or group of parameters used by a coordinate operation or a process.
+ * This interface combines information provided by Referencing by Coordinates (ISO 19111),
+ * Service Metadata (ISO 19115) and Web Processing Services (WPS) standards.
+ * The main information are:
+ *
+ * <table class="ogc">
+ *   <caption>Main parameter properties</caption>
+ *   <tr>
+ *     <th>Getter method</th>
+ *     <th>ISO 19111</th>
+ *     <th>WPS</th>
+ *     <th>ISO 19115</th>
+ *     <th class="sep">Remarks</th>
+ *   </tr>
+ *   <tr>
+ *      <td>{@link #getName()}</td>
+ *      <td>{@code name}</td>
+ *      <td>{@code Identifier}</td>
+ *      <td>{@code name}</td>
+ *      <td class="sep">See {@linkplain #getName() method javadoc} for {@code MemberName} ↔ {@code Identifier} mapping.</td>
+ *   </tr>
+ *   <!-- "Title" (WPS) equivalent to "designation" (Feature), but not yet provided. -->
+ *   <tr>
+ *      <td>{@link #getDescription()}</td>
+ *      <td></td>
+ *      <td>{@code Abstract}</td>
+ *      <td>{@code description}</td>
+ *      <td class="sep">Also known as “definition”.</td>
+ *   </tr>
+ *   <tr>
+ *      <td>{@link #getDirection()}</td>
+ *      <td></td>
+ *      <td></td>
+ *      <td>{@code direction}</td>
+ *      <td class="sep">Tells if the parameter is a WPS {@code Input} or {@code Output} structure.</td>
+ *   </tr>
+ *   <tr>
+ *      <td>{@link #getMinimumOccurs()}</td>
+ *      <td>{@code minimumOccurs}</td>
+ *      <td>{@code MinOccurs}</td>
+ *      <td>{@code optionality}</td>
+ *      <td class="sep">{@code optionality   = (minimumOccurs > 0)}</td>
+ *   </tr>
+ *   <tr>
+ *      <td>{@link #getMaximumOccurs()}</td>
+ *      <td>{@code maximumOccurs}</td>
+ *      <td>{@code MaxOccurs}</td>
+ *      <td>{@code repeatability}</td>
+ *      <td class="sep">{@code repeatability = (maximumOccurs > 1)}</td>
+ *   </tr>
+ * </table>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
  * @version 0.5
  * @module
  */
-abstract class AbstractParameterDescriptor extends AbstractIdentifiedObject implements GeneralParameterDescriptor {
+public abstract class AbstractParameterDescriptor extends AbstractIdentifiedObject implements GeneralParameterDescriptor {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = -4346475760810353590L;
+
+    /**
+     * Key for the {@value} property to be given to the constructor.
+     * This is used for setting the value to be returned by {@link #getDescription()}.
+     */
+    public static final String DESCRIPTION_KEY = "description";
+
+    /**
+     * A narrative explanation of the role of the parameter, or {@code null} if none.
+     */
+    private final InternationalString description;
+
+    /**
+     * The minimum number of times that values for this parameter group are required, as an unsigned short.
+     * We use a short because this value is usually either 0 or 1, or a very small number like 2 or 3.
+     * A large number would be a bad idea with this parameter implementation.
+     */
+    private final short minimumOccurs;
+
+    /**
+     * The maximum number of times that values for this parameter group are required, as an unsigned short.
+     * Value {@code 0xFFFF} (or -1) means an unrestricted number of occurrences.
+     *
+     * <p>We use a short because this value is usually 1 or a very small number like 2 or 3. This also serve
+     * as a safety since a large number would be a bad idea with this parameter implementation.</p>
+     */
+    private final short maximumOccurs;
 
-    protected AbstractParameterDescriptor(final Map<String,?> properties) {
+    /**
+     * Constructs a parameter descriptor from a set of properties. The properties map is given unchanged to the
+     * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+     * The following table is a reminder of main (not all) properties:
+     *
+     * <table class="sis">
+     *   <caption>Recognized properties (non exhaustive list)</caption>
+     *   <tr>
+     *     <th>Property name</th>
+     *     <th>Value type</th>
+     *     <th>Returned by</th>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
+     *     <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
+     *     <td>{@link #getName()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
+     *     <td>{@link org.opengis.util.GenericName} or {@link CharSequence} (optionally as array)</td>
+     *     <td>{@link #getAlias()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
+     *     <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
+     *     <td>{@link #getIdentifiers()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.apache.sis.parameter.AbstractParameterDescriptor#DESCRIPTION_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getDescription()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getRemarks()}</td>
+     *   </tr>
+     * </table>
+     *
+     * @param properties    The properties to be given to the identified object.
+     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times} that values
+     *                      for this parameter group are required, or 0 if no restriction.
+     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times} that values
+     *                      for this parameter group are required, or {@link Integer#MAX_VALUE} if no restriction.
+     */
+    protected AbstractParameterDescriptor(final Map<String,?> properties,
+            final int minimumOccurs, final int maximumOccurs)
+    {
         super(properties);
+        this.description   = Types.toInternationalString(properties, DESCRIPTION_KEY);
+        this.minimumOccurs = (short) minimumOccurs;
+        this.maximumOccurs = (short) maximumOccurs;
+        if (minimumOccurs < 0 || minimumOccurs > maximumOccurs || maximumOccurs == 0) {
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                    Errors.Keys.IllegalRange_2, minimumOccurs, maximumOccurs));
+        }
+        if (maximumOccurs > 0xFFFE && maximumOccurs != Integer.MAX_VALUE) {
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                    Errors.Keys.TooManyOccurrences_2, 0xFFFE, super.getName()));
+        }
+    }
+
+    /**
+     * Constructs a new parameter descriptor 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 descriptor The object to shallow copy.
+     */
+    protected AbstractParameterDescriptor(final GeneralParameterDescriptor descriptor) {
+        super(descriptor);
+        description   = descriptor.getDescription();
+        minimumOccurs = crop(descriptor.getMinimumOccurs());
+        maximumOccurs = crop(descriptor.getMaximumOccurs());
+    }
+
+    /**
+     * Crops the given integer in the [0 … 0xFFFF] range.
+     */
+    private static short crop(final int n) {
+        return (short) Math.max(0, Math.min(0xFFFF, n));
     }
 
-    protected AbstractParameterDescriptor(final GeneralParameterDescriptor other) {
-        super(other);
+    /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code GeneralParameterDescriptor.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
+     *
+     * @return The parameter descriptor interface implemented by this class.
+     */
+    @Override
+    public Class<? extends GeneralParameterDescriptor> getInterface() {
+        return GeneralParameterDescriptor.class;
     }
 
     /**
      * Returns an indication if the parameter is an input to the service, an output or both.
+     * The default implementation returns {@link ParameterDirection#IN}.
      *
      * @return Indication if the parameter is an input or output to the service, or {@code null} if unspecified.
      */
@@ -58,28 +243,127 @@ abstract class AbstractParameterDescript
      */
     @Override
     public InternationalString getDescription() {
-        return null;
+        return description;
     }
 
     /**
      * The minimum number of times that values for this parameter group or parameter are required.
-     * The default value is 1. A value of 0 means an optional parameter.
+     * A value of 0 means an optional parameter.
      *
      * @return The minimum occurrence.
      */
     @Override
     public int getMinimumOccurs() {
-        return 1;
+        return Short.toUnsignedInt(minimumOccurs);
     }
 
     /**
      * The maximum number of times that values for this parameter group or parameter can be included.
-     * The default value is 1. A value grater than 1 means a repeatable parameter.
+     * A value greater than 1 means a repeatable parameter.
      *
      * @return The maximum occurrence.
      */
     @Override
     public int getMaximumOccurs() {
-        return 1;
+        return (maximumOccurs != -1) ? Short.toUnsignedInt(maximumOccurs) : Integer.MAX_VALUE;
+    }
+
+    /**
+     * Compares the specified object with this parameter for equality.
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public boolean equals(final Object object, final ComparisonMode mode) {
+        if (super.equals(object, mode)) {
+            switch (mode) {
+                case STRICT: {
+                    final AbstractParameterDescriptor that = (AbstractParameterDescriptor) object;
+                    return minimumOccurs == that.minimumOccurs &&
+                           maximumOccurs == that.maximumOccurs &&
+                           Objects.equals(description, that.description);
+                }
+                default: {
+                    final GeneralParameterDescriptor that = (GeneralParameterDescriptor) object;
+                    return getMinimumOccurs() == that.getMinimumOccurs() &&
+                           getMaximumOccurs() == that.getMaximumOccurs() &&
+                           deepEquals(getDescription(), that.getDescription(), mode);
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns a string representation of this descriptor.
+     *
+     * <p>This method is for information purpose only and may change in future SIS version.</p>
+     */
+    @Debug
+    @Override
+    public String toString() {
+        if (this instanceof ParameterDescriptorGroup) {
+            return ParameterFormat.sharedFormat(this);
+        } else {
+            return super.toString();
+        }
+    }
+
+    /**
+     * Prints a string representation of this descriptor to the {@linkplain System#out standard output stream}.
+     * If a {@linkplain java.io.Console console} is attached to the running JVM (i.e. if the application is run
+     * from the command-line and the output is not redirected to a file) and if Apache SIS thinks that the console
+     * supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
+     *
+     * <p>This is a convenience method for debugging purpose and for console applications.</p>
+     */
+    @Debug
+    @Override
+    public void print() {
+        if (this instanceof ParameterDescriptorGroup) {
+            ParameterFormat.print(this);
+        } else {
+            super.print();
+        }
+    }
+
+    /**
+     * Formats this descriptor as a pseudo-<cite>Well Known Text</cite> element. The WKT specification
+     * does not define any representation of parameter descriptors. Apache SIS fallback on a list of
+     * {@linkplain DefaultParameterDescriptor#formatTo(Formatter) descriptors}.
+     * The text formatted by this method is {@linkplain Formatter#setInvalidWKT flagged as invalid WKT}.
+     *
+     * @param  formatter The formatter where to format the inner content of this WKT element.
+     * @return {@code "Parameter"} or {@code "ParameterGroup"}.
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        super.formatTo(formatter);
+        formatter.setInvalidWKT(this, null);
+        if (this instanceof ParameterDescriptorGroup) {
+            for (GeneralParameterDescriptor parameter : ((ParameterDescriptorGroup) this).descriptors()) {
+                if (!(parameter instanceof FormattableObject)) {
+                    if (parameter instanceof ParameterDescriptor<?>) {
+                        parameter = new DefaultParameterDescriptor<>((ParameterDescriptor<?>) parameter);
+                    } else if (parameter instanceof ParameterDescriptorGroup) {
+                        parameter = new DefaultParameterDescriptorGroup((ParameterDescriptorGroup) parameter);
+                    } else {
+                        continue;
+                    }
+                }
+                formatter.newLine();
+                formatter.append((FormattableObject) parameter);
+            }
+            return "ParameterGroup";
+        } else if (this instanceof ParameterDescriptor<?>) {
+            formatter.appendAny(((ParameterDescriptor<?>) this).getDefaultValue());
+            final Unit<?> unit = ((ParameterDescriptor<?>) this).getUnit();
+            if (unit != null) {
+                if (!formatter.getConvention().isSimplified() || !unit.equals(formatter.toContextualUnit(unit))) {
+                    formatter.append(unit);
+                }
+            }
+        }
+        return "Parameter";
     }
 }

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=1625166&r1=1625165&r2=1625166&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] Mon Sep 15 21:22:26 2014
@@ -27,15 +27,11 @@ import org.apache.sis.util.Classes;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.io.wkt.Formatter;
-import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.CollectionsExt;
-import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.ArgumentChecks.ensureCanCast;
@@ -78,14 +74,7 @@ public class DefaultParameterDescriptor<
     /**
      * Serial number for inter-operability with different versions.
      */
-    private static final long serialVersionUID = 7433401733923393656L;
-
-    /**
-     * {@code true} if this parameter is mandatory, or {@code false} if it is optional.
-     *
-     * @see #getMinimumOccurs()
-     */
-    private final boolean required;
+    private static final long serialVersionUID = -1978932430298071693L;
 
     /**
      * The class that describe the type of parameter values.
@@ -126,7 +115,7 @@ public class DefaultParameterDescriptor<
 
     /**
      * Constructs a descriptor from the given properties. The properties map is given unchanged to the
-     * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+     * {@linkplain AbstractParameterDescriptor#AbstractParameterDescriptor(Map) super-class constructor}.
      * The following table is a reminder of main (not all) properties:
      *
      * <table class="sis">
@@ -152,6 +141,11 @@ public class DefaultParameterDescriptor<
      *     <td>{@link #getIdentifiers()}</td>
      *   </tr>
      *   <tr>
+     *     <td>{@value org.apache.sis.parameter.AbstractParameterDescriptor#DESCRIPTION_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getDescription()}</td>
+     *   </tr>
+     *   <tr>
      *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
      *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
      *     <td>{@link #getRemarks()}</td>
@@ -179,25 +173,29 @@ public class DefaultParameterDescriptor<
      * If both {@code valueDomain} and {@code validValues} are non-null, then all valid values shall be contained
      * in the value domain.
      *
-     * @param properties   The properties to be given to the identified object.
-     * @param valueClass   The class that describes the type of the parameter value.
-     * @param valueDomain  The minimum value, maximum value and unit of measurement, or {@code null} if none.
-     * @param validValues  The list of valid values, or {@code null} if there is no restriction.
-     *                     This property is mostly for restricting values to a {@linkplain CodeList code list}
-     *                     or enumeration subset. It is not necessary to provide this property when all values
-     *                     from the code list or enumeration are valid.
-     * @param defaultValue The default value for the parameter, or {@code null} if none.
-     * @param required     {@code true} if this parameter is mandatory, or {@code false} if it is optional.
+     * @param properties    The properties to be given to the identified object.
+     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times} that values
+     *                      for this parameter group are required, or 0 if no restriction.
+     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times} that values
+     *                      for this parameter group are required, or {@link Integer#MAX_VALUE} if no restriction.
+     * @param valueClass    The class that describes the type of the parameter value.
+     * @param valueDomain   The minimum value, maximum value and unit of measurement, or {@code null} if none.
+     * @param validValues   The list of valid values, or {@code null} if there is no restriction.
+     *                      This property is mostly for restricting values to a {@linkplain CodeList code list}
+     *                      or enumeration subset. It is not necessary to provide this property when all values
+     *                      from the code list or enumeration are valid.
+     * @param defaultValue  The default value for the parameter, or {@code null} if none.
      */
     @SuppressWarnings("unchecked")
     public DefaultParameterDescriptor(final Map<String,?> properties,
+                                      final int           minimumOccurs,
+                                      final int           maximumOccurs,
                                       final Class<T>      valueClass,
                                       final Range<?>      valueDomain,
                                       final T[]           validValues,
-                                      final T             defaultValue,
-                                      final boolean       required)
+                                      final T             defaultValue)
     {
-        super(properties);
+        super(properties, minimumOccurs, maximumOccurs);
         ensureNonNull("valueClass",   valueClass);
         ensureCanCast("defaultValue", valueClass, defaultValue);
         if (valueDomain != null) {
@@ -218,7 +216,6 @@ public class DefaultParameterDescriptor<
                         .getString(Errors.Keys.IllegalRange_2, valueDomain.getMinValue(), valueDomain.getMaxValue()));
             }
         }
-        this.required     = required;
         this.valueClass   = valueClass;
         this.valueDomain  = valueDomain;
         this.defaultValue = Numerics.cached(defaultValue);
@@ -254,6 +251,33 @@ public class DefaultParameterDescriptor<
     }
 
     /**
+     * Creates an optional or mandatory parameter. As a consequence of the merge with ISO 19115 {@code SV_Parameter},
+     * {@code DefaultParameterDescriptor} has been generalized to accept an arbitrary amount of occurrences.
+     *
+     * @param properties   The properties to be given to the identified object.
+     * @param valueClass   The class that describes the type of the parameter value.
+     * @param valueDomain  The minimum value, maximum value and unit of measurement, or {@code null} if none.
+     * @param validValues  The list of valid values, or {@code null} if there is no restriction.
+     *                     This property is mostly for restricting values to a {@linkplain CodeList code list}
+     *                     or enumeration subset. It is not necessary to provide this property when all values
+     *                     from the code list or enumeration are valid.
+     * @param defaultValue The default value for the parameter, or {@code null} if none.
+     * @param required     {@code true} if this parameter is mandatory, or {@code false} if it is optional.
+     *
+     * @deprecated Replaced by the constructor with explicit minimum and maximum number of occurrences.
+     */
+    @Deprecated
+    public DefaultParameterDescriptor(final Map<String,?> properties,
+                                      final Class<T>      valueClass,
+                                      final Range<?>      valueDomain,
+                                      final T[]           validValues,
+                                      final T             defaultValue,
+                                      final boolean       required)
+    {
+        this(properties, required ? 1 : 0, 1, valueClass, valueDomain, validValues, defaultValue);
+    }
+
+    /**
      * Creates a new descriptor 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.
@@ -267,7 +291,6 @@ public class DefaultParameterDescriptor<
     @SuppressWarnings("unchecked")
     protected DefaultParameterDescriptor(final ParameterDescriptor<T> descriptor) {
         super(descriptor);
-        required     = descriptor.getMinimumOccurs() != 0;
         valueClass   = descriptor.getValueClass();
         validValues  = descriptor.getValidValues();
         defaultValue = descriptor.getDefaultValue();
@@ -308,30 +331,6 @@ public class DefaultParameterDescriptor<
     }
 
     /**
-     * The minimum number of times that values for this parameter are required.
-     * A value of 0 means an optional parameter and a value of 1 means a mandatory parameter.
-     *
-     * @see #getMaximumOccurs()
-     */
-    @Override
-    public int getMinimumOccurs() {
-        return required ? 1 : 0;
-    }
-
-    /**
-     * The maximum number of times that values for this parameter can be included.
-     * For a {@code ParameterDescriptor}, the value is always 1.
-     *
-     * @return The maximum occurrence.
-     *
-     * @see #getMinimumOccurs()
-     */
-    @Override
-    public int getMaximumOccurs() {
-        return 1;
-    }
-
-    /**
      * 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.
@@ -507,8 +506,7 @@ public class DefaultParameterDescriptor<
                 }
                 case STRICT: {
                     final DefaultParameterDescriptor<?> that = (DefaultParameterDescriptor<?>) object;
-                    return                    this.required   == that.required     &&
-                                              this.valueClass == that.valueClass   &&
+                    return                    this.valueClass == that.valueClass   &&
                            Objects.    equals(this.validValues,  that.validValues) &&
                            Objects.    equals(this.valueDomain,  that.valueDomain) &&
                            Objects.deepEquals(this.defaultValue, that.defaultValue);
@@ -525,31 +523,6 @@ public class DefaultParameterDescriptor<
      */
     @Override
     protected long computeHashCode() {
-        return Arrays.deepHashCode(new Object[] {required, valueClass, valueDomain, defaultValue})
-                + super.computeHashCode();
-    }
-
-    /**
-     * Formats this parameter as a pseudo-<cite>Well Known Text</cite> element. The WKT specification
-     * does not define any representation of parameter descriptors. Apache SIS fallback on the
-     * {@linkplain DefaultParameterValue#formatTo(Formatter) same representation than parameter value},
-     * with the descriptor {@linkplain #getDefaultValue() default value} in place of the parameter value.
-     * The text formatted by this method is {@linkplain Formatter#setInvalidWKT flagged as invalid WKT}.
-     *
-     * @param  formatter The formatter where to format the inner content of this WKT element.
-     * @return {@code "Parameter"}.
-     */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendName(this, formatter, ElementKind.PARAMETER);
-        formatter.setInvalidWKT(this, null);
-        formatter.appendAny(defaultValue);
-        final Unit<?> unit = getUnit();
-        if (unit != null) {
-            if (!formatter.getConvention().isSimplified() || !unit.equals(formatter.toContextualUnit(unit))) {
-                formatter.append(unit);
-            }
-        }
-        return "Parameter";
+        return Arrays.deepHashCode(new Object[] {valueClass, valueDomain, defaultValue}) + super.computeHashCode();
     }
 }

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=1625166&r1=1625165&r2=1625166&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] Mon Sep 15 21:22:26 2014
@@ -22,21 +22,15 @@ import java.util.List;
 import java.util.HashSet;
 import java.util.Collections;
 import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.parameter.InvalidParameterNameException;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
-import org.apache.sis.internal.referencing.WKTUtilities;
-import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -99,17 +93,7 @@ public class DefaultParameterDescriptorG
     /**
      * Serial number for inter-operability with different versions.
      */
-    private static final long serialVersionUID = -4613190550542423839L;
-
-    /**
-     * The minimum number of times that values for this parameter group are required.
-     */
-    private final int minimumOccurs;
-
-    /**
-     * The maximum number of times that values for this parameter group are required.
-     */
-    private final int maximumOccurs;
+    private static final long serialVersionUID = 6058599597772994456L;
 
     /**
      * The {@linkplain #descriptors() parameter descriptors} for this group.
@@ -118,7 +102,7 @@ public class DefaultParameterDescriptorG
 
     /**
      * Constructs a parameter group from a set of properties. The properties map is given unchanged to the
-     * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+     * {@linkplain AbstractParameterDescriptor#AbstractParameterDescriptor(Map) super-class constructor}.
      * The following table is a reminder of main (not all) properties:
      *
      * <table class="sis">
@@ -144,6 +128,11 @@ public class DefaultParameterDescriptorG
      *     <td>{@link #getIdentifiers()}</td>
      *   </tr>
      *   <tr>
+     *     <td>{@value org.apache.sis.parameter.AbstractParameterDescriptor#DESCRIPTION_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getDescription()}</td>
+     *   </tr>
+     *   <tr>
      *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
      *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
      *     <td>{@link #getRemarks()}</td>
@@ -151,10 +140,10 @@ public class DefaultParameterDescriptorG
      * </table>
      *
      * @param properties    The properties to be given to the identified object.
-     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times}
-     *                      that values for this parameter group are required.
-     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times}
-     *                      that values for this parameter group are required.
+     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times} that values
+     *                      for this parameter group are required, or 0 if no restriction.
+     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times} that values
+     *                      for this parameter group are required, or {@link Integer#MAX_VALUE} if no restriction.
      * @param parameters    The {@linkplain #descriptors() parameter descriptors} for this group.
      *
      * @throws InvalidParameterNameException If a parameter name is duplicated.
@@ -162,13 +151,7 @@ public class DefaultParameterDescriptorG
     public DefaultParameterDescriptorGroup(final Map<String,?> properties,
             final int minimumOccurs, final int maximumOccurs, GeneralParameterDescriptor... parameters)
     {
-        super(properties);
-        this.minimumOccurs = minimumOccurs;
-        this.maximumOccurs = maximumOccurs;
-        if (minimumOccurs < 0  || minimumOccurs > maximumOccurs || maximumOccurs == 0) {
-            throw new IllegalArgumentException(Errors.getResources(properties).getString(
-                    Errors.Keys.IllegalRange_2, minimumOccurs, maximumOccurs));
-        }
+        super(properties, minimumOccurs, maximumOccurs);
         ArgumentChecks.ensureNonNull("parameters", parameters);
         parameters = parameters.clone();
         for (int i=0; i<parameters.length; i++) {
@@ -198,8 +181,6 @@ public class DefaultParameterDescriptorG
      */
     protected DefaultParameterDescriptorGroup(final ParameterDescriptorGroup descriptor) {
         super(descriptor);
-        minimumOccurs = descriptor.getMinimumOccurs();
-        maximumOccurs = descriptor.getMaximumOccurs();
         final List<GeneralParameterDescriptor> c = descriptor.descriptors();
         if (descriptor instanceof DefaultParameterDescriptorGroup &&
                 ((DefaultParameterDescriptorGroup) descriptor).descriptors == c)
@@ -282,27 +263,6 @@ public class DefaultParameterDescriptorG
     }
 
     /**
-     * The minimum number of times that values for this parameter group or parameter are required.
-     * A value of 0 means an optional parameter.
-     *
-     * @return The minimum occurrence.
-     */
-    @Override
-    public int getMinimumOccurs() {
-        return minimumOccurs;
-    }
-
-    /**
-     * The maximum number of times that values for this parameter group are required.
-     *
-     * @return The maximum occurrence.
-     */
-    @Override
-    public int getMaximumOccurs() {
-        return maximumOccurs;
-    }
-
-    /**
      * 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
@@ -375,16 +335,10 @@ public class DefaultParameterDescriptorG
         if (super.equals(object, mode)) {
             switch (mode) {
                 case STRICT: {
-                    final DefaultParameterDescriptorGroup that = (DefaultParameterDescriptorGroup) object;
-                    return minimumOccurs == that.minimumOccurs &&
-                           maximumOccurs == that.maximumOccurs &&
-                           descriptors.equals(that.descriptors);
+                    return descriptors.equals(((DefaultParameterDescriptorGroup) object).descriptors);
                 }
                 default: {
-                    final ParameterDescriptorGroup that = (ParameterDescriptorGroup) object;
-                    return getMinimumOccurs() == that.getMinimumOccurs() &&
-                           getMaximumOccurs() == that.getMaximumOccurs() &&
-                           deepEquals(descriptors(), that.descriptors(), mode);
+                    return deepEquals(descriptors(), ((ParameterDescriptorGroup) object).descriptors(), mode);
                 }
             }
         }
@@ -400,59 +354,4 @@ public class DefaultParameterDescriptorG
     protected long computeHashCode() {
         return super.computeHashCode() + descriptors.hashCode();
     }
-
-    /**
-     * Returns a string representation of this descriptor.
-     * The default implementation delegates to {@link ParameterFormat}.
-     *
-     * <p>This method is for information purpose only and may change in future SIS version.</p>
-     */
-    @Debug
-    @Override
-    public String toString() {
-        return ParameterFormat.sharedFormat(this);
-    }
-
-    /**
-     * Prints a string representation of this descriptor to the {@linkplain System#out standard output stream}.
-     * If a {@linkplain java.io.Console console} is attached to the running JVM (i.e. if the application is run
-     * from the command-line and the output is not redirected to a file) and if Apache SIS thinks that the console
-     * supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
-     *
-     * <p>This is a convenience method for debugging purpose and for console applications.</p>
-     */
-    @Debug
-    @Override
-    public void print() {
-        ParameterFormat.print(this);
-    }
-
-    /**
-     * Formats this group as a pseudo-<cite>Well Known Text</cite> element. The WKT specification
-     * does not define any representation of parameter descriptors. Apache SIS fallback on a list
-     * of {@linkplain DefaultParameterDescriptor#formatTo(Formatter) single descriptors}.
-     * The text formatted by this method is {@linkplain Formatter#setInvalidWKT flagged as invalid WKT}.
-     *
-     * @param  formatter The formatter where to format the inner content of this WKT element.
-     * @return {@code "ParameterGroup"}.
-     */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendName(this, formatter, null);
-        formatter.setInvalidWKT(this, null);
-        for (GeneralParameterDescriptor parameter : descriptors) {
-            if (!(parameter instanceof FormattableObject)) {
-                if (parameter instanceof ParameterDescriptor<?>) {
-                    parameter = new DefaultParameterDescriptor<>((ParameterDescriptor<?>) parameter);
-                } else if (parameter instanceof ParameterDescriptorGroup) {
-                    parameter = new DefaultParameterDescriptorGroup((ParameterDescriptorGroup) parameter);
-                } else {
-                    continue;
-                }
-            }
-            formatter.newLine();
-            formatter.append((FormattableObject) parameter);
-        }
-        return "ParameterGroup";
-    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -276,8 +276,8 @@ public class ParameterBuilder extends Bu
         final ParameterDescriptor<T> descriptor;
         onCreate(false);
         try {
-            descriptor = new DefaultParameterDescriptor<>(properties,
-                    valueClass, valueDomain, validValues, defaultValue, required);
+            descriptor = new DefaultParameterDescriptor<>(properties, required ? 1 : 0, 1,
+                    valueClass, valueDomain, validValues, defaultValue);
         } finally {
             onCreate(true);
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -141,15 +141,21 @@ public final class Parameters extends St
 
     /**
      * Gets the parameter name as an instance of {@code MemberName}.
-     * This method first checks if the {@linkplain DefaultParameterDescriptor#getName()} primary name is an instance of
-     * {@code MemberName}. If not, this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias()
-     * alias} which is an instance of {@code MemberName}. If none is found, then this method tries to build a member name
-     * from the primary name and {@linkplain DefaultParameterDescriptor#getValueClass() value class} using the mapping
-     * defined in {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.
+     * This method performs the following checks:
      *
-     * <p>This method can be used as a bridge between the parameter object
+     * <ul>
+     *   <li>If the {@linkplain DefaultParameterDescriptor#getName()} primary name is an instance of {@code MemberName},
+     *       returns that primary name.</li>
+     *   <li>Otherwise this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias() alias}
+     *       which is an instance of {@code MemberName}. If found, that alias is returned.</li>
+     *   <li>If no alias is found, then this method tries to build a member name from the primary name and the
+     *       {@linkplain DefaultParameterDescriptor#getValueClass() value class}, using the mapping defined in
+     *       {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.</li>
+     * </ul>
+     *
+     * This method can be used as a bridge between the parameter object
      * defined by ISO 19111 (namely {@code CC_OperationParameter}) and the one
-     * defined by ISO 19115 (namely {@code SV_Parameter}).</p>
+     * defined by ISO 19115 (namely {@code SV_Parameter}).
      *
      * @param  parameter The parameter from which to get the name (may be {@code null}).
      * @return The member name, or {@code null} if none.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -140,9 +140,9 @@ public class TensorParameters<E> impleme
         final Map<String,Object> properties = new HashMap<>(4);
         properties.put(ReferenceIdentifier.AUTHORITY_KEY, Citations.OGC);
         properties.put(ReferenceIdentifier.CODE_KEY, "num_row");
-        numRow = new DefaultParameterDescriptor<>(properties, Integer.class, valueDomain, null, defaultSize, true);
+        numRow = new DefaultParameterDescriptor<>(properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
         properties.put(ReferenceIdentifier.CODE_KEY, "num_col");
-        numCol = new DefaultParameterDescriptor<>(properties, Integer.class, valueDomain, null, defaultSize, true);
+        numCol = new DefaultParameterDescriptor<>(properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
         WKT1 = new TensorParameters<>(Double.class, "elt_", "_", numRow, numCol);
     }
 
@@ -379,7 +379,7 @@ public class TensorParameters<E> impleme
         final Map<String,Object> properties = new HashMap<>(4);
         properties.put(ReferenceIdentifier.CODE_KEY, indicesToName(indices));
         properties.put(ReferenceIdentifier.AUTHORITY_KEY, dimensions[0].getName().getAuthority());
-        return new DefaultParameterDescriptor<>(properties, elementType, null, null, isDiagonal ? one : zero, false);
+        return new DefaultParameterDescriptor<>(properties, 0, 1, elementType, null, null, isDiagonal ? one : zero);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -34,6 +34,7 @@ import org.apache.sis.referencing.Identi
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Classes;
@@ -41,7 +42,6 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.Debug;
 
 
 /**
@@ -89,7 +89,7 @@ final class TensorValues<E> extends Abst
      */
     @SuppressWarnings({"unchecked","rawtypes"})
     TensorValues(final Map<String,?> properties, final TensorParameters<E> descriptors) {
-        super(properties);
+        super(properties, 1, 1);
         this.descriptors = descriptors;
         dimensions = new ParameterValue[descriptors.rank()];
         for (int i=0; i<dimensions.length; i++) {
@@ -436,24 +436,6 @@ final class TensorValues<E> extends Abst
     }
 
     /**
-     * Returns a string representation of this group.
-     */
-    @Debug
-    @Override
-    public String toString() {
-        return ParameterFormat.sharedFormat(this);
-    }
-
-    /**
-     * Prints a string representation of this group to the {@linkplain System#out standard output stream}.
-     */
-    @Debug
-    @Override
-    public void print() {
-        ParameterFormat.print(this);
-    }
-
-    /**
      * Formats this group as a pseudo-<cite>Well Known Text</cite> element.
      *
      * @param  formatter The formatter where to format the inner content of this WKT element.
@@ -461,7 +443,7 @@ final class TensorValues<E> extends Abst
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        super.formatTo(formatter);
+        WKTUtilities.appendName(this, formatter, ElementKind.PARAMETER);
         WKTUtilities.append(this, formatter);
         return "ParameterGroup";
     }

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=1625166&r1=1625165&r2=1625166&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] Mon Sep 15 21:22:26 2014
@@ -54,10 +54,10 @@ public final strictfp class DefaultParam
         final Class<Integer> type = Integer.class;
         final Map<String,Object> properties = new HashMap<>(4);
         M1_M1_O1_O2 = new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"), 0, 1,
-            new DefaultParameterDescriptor<>(name(properties, "Mandatory 1", "Ambiguity"), type, null, null, DEFAULT_VALUE, true),
-            new DefaultParameterDescriptor<>(name(properties, "Mandatory 2", "Alias 2"),   type, null, null, DEFAULT_VALUE, true),
-            new DefaultParameterDescriptor<>(name(properties,  "Optional 3", "Alias 3"),   type, null, null, DEFAULT_VALUE, false),
-            new MultiOccurrenceDescriptor <>(name(properties,  "Optional 4", "Ambiguity"), type, null, null, DEFAULT_VALUE, false)
+            new DefaultParameterDescriptor<>(name(properties, "Mandatory 1", "Ambiguity"), 1, 1, type, null, null, DEFAULT_VALUE),
+            new DefaultParameterDescriptor<>(name(properties, "Mandatory 2", "Alias 2"),   1, 1, type, null, null, DEFAULT_VALUE),
+            new DefaultParameterDescriptor<>(name(properties, "Optional 3", "Alias 3"),    0, 1, type, null, null, DEFAULT_VALUE),
+            new DefaultParameterDescriptor<>(name(properties, "Optional 4", "Ambiguity"),  0, 2, type, null, null, DEFAULT_VALUE)
         );
     }
 
@@ -78,8 +78,8 @@ public final strictfp class DefaultParam
         final Class<Integer> type = Integer.class;
         final Map<String,Object> properties = new HashMap<>(4);
         final DefaultParameterDescriptor<Integer> p1, p2;
-        p1 = new DefaultParameterDescriptor<>(name(properties, "Name", null), type, null, null, null, true);
-        p2 = new DefaultParameterDescriptor<>(name(properties, "  NAME ", null), type, null, null, null, true);
+        p1 = new DefaultParameterDescriptor<>(name(properties,    "Name", null), 1, 1, type, null, null, null);
+        p2 = new DefaultParameterDescriptor<>(name(properties, "  NAME ", null), 1, 1, type, null, null, null);
         try {
             new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"), 0, 1, p1, p2);
             fail("Constructor should have detected the duplicated names.");
@@ -102,7 +102,7 @@ public final strictfp class DefaultParam
             } catch (AssertionError e) {
                 error = e;
             }
-            if (descriptor instanceof MultiOccurrenceDescriptor) {
+            if (descriptor.getMaximumOccurs() > 1) {
                 assertNotNull("Validation methods should have detected that the descriptor is invalid.", error);
             } else if (error != null) {
                 throw error;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -65,7 +65,7 @@ public final strictfp class DefaultParam
      * @return The parameter descriptor.
      */
     static <T> DefaultParameterDescriptor<T> createSimpleOptional(final String name, final Class<T> type) {
-        return new DefaultParameterDescriptor<>(properties(name), type, null, null, null, false);
+        return new DefaultParameterDescriptor<>(properties(name), 0, 1, type, null, null, null);
     }
 
     /**
@@ -80,8 +80,8 @@ public final strictfp class DefaultParam
     static DefaultParameterDescriptor<Integer> create(final String name,
             final int minimumValue, final int maximumValue, final int defaultValue)
     {
-        return new DefaultParameterDescriptor<>(properties(name), Integer.class,
-                NumberRange.create(minimumValue, true, maximumValue, true), null, Integer.valueOf(defaultValue), true);
+        return new DefaultParameterDescriptor<>(properties(name), 1, 1, Integer.class,
+                NumberRange.create(minimumValue, true, maximumValue, true), null, Integer.valueOf(defaultValue));
     }
 
     /**
@@ -97,9 +97,9 @@ public final strictfp class DefaultParam
     static DefaultParameterDescriptor<Double> create(final String name,
             final double minimumValue, final double maximumValue, final double defaultValue, final Unit<?> unit)
     {
-        return new DefaultParameterDescriptor<>(properties(name), Double.class,
+        return new DefaultParameterDescriptor<>(properties(name), 1, 1, Double.class,
                 MeasurementRange.create(minimumValue, true, maximumValue, true, unit), null,
-                Double.isNaN(defaultValue) ? null : Double.valueOf(defaultValue), true);
+                Double.isNaN(defaultValue) ? null : Double.valueOf(defaultValue));
     }
 
     /**
@@ -115,7 +115,7 @@ public final strictfp class DefaultParam
     static <T> DefaultParameterDescriptor<T> create(final String name, final Class<T> type,
             final T[] validValues, final T defaultValue)
     {
-        return new DefaultParameterDescriptor<>(properties(name), type, null, validValues, defaultValue, true);
+        return new DefaultParameterDescriptor<>(properties(name), 1, 1, type, null, validValues, defaultValue);
     }
 
     /**
@@ -131,7 +131,7 @@ public final strictfp class DefaultParam
             final double minimumValue, final double maximumValue, final Unit<?> unit)
     {
         final MeasurementRange<Double> valueDomain = MeasurementRange.create(minimumValue, true, maximumValue, true, unit);
-        return new DefaultParameterDescriptor<>(properties(name), double[].class, valueDomain, null, null, true);
+        return new DefaultParameterDescriptor<>(properties(name), 1, 1, double[].class, valueDomain, null, null);
     }
 
     /**
@@ -210,7 +210,7 @@ public final strictfp class DefaultParam
     public void testStringType() {
         final Range<String> valueDomain = new Range<>(String.class, "AAA", true, "BBB", true);
         final DefaultParameterDescriptor<String> descriptor = new DefaultParameterDescriptor<>(
-                properties("String param"), String.class, valueDomain, null, "ABC", false);
+                properties("String param"), 0, 1, String.class, valueDomain, null, "ABC");
         assertEquals("name", "String param",     descriptor.getName().getCode());
         assertEquals("valueClass", String.class, descriptor.getValueClass());
         assertNull  ("validValues",              descriptor.getValidValues());
@@ -277,8 +277,8 @@ public final strictfp class DefaultParam
          * Invalid operation: wrong type of range value.
          */
         try {
-            new DefaultParameterDescriptor<>(properties("Array param"), double[].class,
-                    NumberRange.create(4, true, 9, true), null, null, false);
+            new DefaultParameterDescriptor<>(properties("Array param"), 0, 1,
+                    double[].class, NumberRange.create(4, true, 9, true), null, null);
         } catch (IllegalArgumentException e) {
             assertEquals("Argument ‘valueDomain’ can not be an instance of ‘Range<Integer>’.", e.getMessage());
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java?rev=1625166&r1=1625165&r2=1625166&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java [UTF-8] Mon Sep 15 21:22:26 2014
@@ -102,7 +102,7 @@ public final strictfp class DefaultParam
             } catch (AssertionError e) {
                 error = e;
             }
-            if (param.getDescriptor() instanceof MultiOccurrenceDescriptor) {
+            if (param.getDescriptor().getMaximumOccurs() > 1) {
                 assertNotNull("Validation methods should have detected that the descriptor is invalid.", error);
             } else if (error != null) {
                 throw error;
@@ -237,7 +237,7 @@ public final strictfp class DefaultParam
         final DefaultParameterValueGroup    group = createGroup(10);
         final List<GeneralParameterValue>  values = group.values();
         final ParameterValue<Integer> nonExistent = new DefaultParameterDescriptor<>(
-                singletonMap(NAME_KEY, "Optional 5"), Integer.class, null, null, null, false).createValue();
+                singletonMap(NAME_KEY, "Optional 5"), 0, 1, Integer.class, null, null, null).createValue();
         try {
             values.add(nonExistent);
             fail("“Optional 5” is not a parameter for this group.");



Mime
View raw message