Class DefaultParameterDescriptor<T>

Type Parameters:
T - the type of elements to be returned by DefaultParameterValue.getValue().
All Implemented Interfaces:
Serializable, Formattable, Deprecable, LenientComparable, org.opengis.parameter.GeneralParameterDescriptor, org.opengis.parameter.ParameterDescriptor<T>, org.opengis.referencing.IdentifiedObject

public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor implements org.opengis.parameter.ParameterDescriptor<T>
The definition of a single parameter used by an operation method. For Coordinate Reference Systems most parameter values are numeric, but other types of parameter values are possible.

A parameter descriptor contains the following properties:

Since:
0.4
Version:
1.3
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for inter-operability with different versions.
      See Also:
    • valueClass

      private Class<T> valueClass
      The class that describe the type of parameter values. This field should be considered final after construction. This is declared non-final only for GML unmarshalling.
      See Also:
    • validValues

      private final Set<T> validValues
      A set of valid values (usually from a code list) or null if it does not apply. This set is immutable.
      See Also:
    • valueDomain

      private Range<?> valueDomain
      The minimum and maximum parameter value with their unit of measurement, or null if none. If this field is non-null, then valueDomain.getElementType() shall be one of the following:
      • If valueClass is not an array, then the range element type shall be the same class.
      • If valueClass is an array, then the range element type shall be the wrapper of valueClass.getComponentType().
      This field should be considered final after construction. This is declared non-final only for GML unmarshalling.
      See Also:
    • defaultValue

      private final T defaultValue
      The default value for the parameter, or null.
      See Also:
  • Constructor Details

    • DefaultParameterDescriptor

      public DefaultParameterDescriptor(Map<String,?> properties, int minimumOccurs, int maximumOccurs, Class<T> valueClass, Range<?> valueDomain, T[] validValues, T defaultValue)
      Constructs a descriptor from the given properties. The properties map is given unchanged to the super-class constructor. The following table is a reminder of main (not all) properties:
      Recognized properties (non exhaustive list)
      Property name Value type Returned by
      "name" ReferenceIdentifier or String AbstractIdentifiedObject.getName()
      "alias" GenericName or CharSequence (optionally as array) AbstractIdentifiedObject.getAlias()
      "identifiers" ReferenceIdentifier (optionally as array) AbstractIdentifiedObject.getIdentifiers()
      "description" InternationalString or String AbstractIdentifiedObject.getDescription()
      "remarks" InternationalString or String AbstractIdentifiedObject.getRemarks()
      The valueDomain argument combines the minimum value, maximum value, unit of measurement (if any) and information about whether the bounds are inclusive or exclusive. If this argument is non-null, then it shall comply to the following conditions: If both valueDomain and validValues are non-null, then all valid values shall be contained in the value domain.
      Parameters:
      properties - the properties to be given to the identified object.
      minimumOccurs - the minimum number of times that values for this parameter group are required, or 0 if no restriction.
      maximumOccurs - the maximum number of times that values for this parameter group are required, or Integer.MAX_VALUE if no restriction.
      valueClass - the class that describes the type of the parameter value.
      valueDomain - the minimum value, maximum value and unit of measurement, or null if none.
      validValues - the list of valid values, or null if there is no restriction. This property is mostly for restricting values to a code list or enumeration subset. It is not necessary to provide this property when all values from the code list or enumeration are valid.
      defaultValue - the default value for the parameter, or null if none.
    • DefaultParameterDescriptor

      protected DefaultParameterDescriptor(org.opengis.parameter.ParameterDescriptor<T> descriptor)
      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.

      This constructor performs a shallow copy, i.e. the properties are not cloned.

      Parameters:
      descriptor - the descriptor to shallow copy.
      See Also:
    • DefaultParameterDescriptor

      private DefaultParameterDescriptor()
      Constructs a new object in which attributes may be set to a null value. This is not a valid object. This constructor is strictly reserved to JAXB, which will assign values to the fields using reflection.

      This constructor fetches the value class and the unit of measurement from the enclosing DefaultParameterValue, if presents, because those information are not presents in GML. They are GeoAPI additions.

  • Method Details

    • castOrCopy

      public static <T> DefaultParameterDescriptor<T> castOrCopy(org.opengis.parameter.ParameterDescriptor<T> object)
      Returns a SIS parameter implementation with the same values than the given arbitrary implementation. If the given object is null, then this method returns null. Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. Otherwise a new SIS implementation is created and initialized to the values of the given object.
      Type Parameters:
      T - the type of values.
      Parameters:
      object - the object to get as a SIS implementation, or null if none.
      Returns:
      a SIS implementation containing the values of the given object (may be the given object itself), or null if the argument was null.
    • getInterface

      public Class<? extends org.opengis.parameter.ParameterDescriptor<T>> getInterface()
      Returns the GeoAPI interface implemented by this class. The SIS implementation returns ParameterDescriptor.class.
      Note for implementers: Subclasses usually do not need to override this method since GeoAPI does not define ParameterDescriptor sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their own set of interfaces.
      Overrides:
      getInterface in class AbstractParameterDescriptor
      Returns:
      ParameterDescriptor.class or a user-defined sub-interface.
    • getValueType

      public org.opengis.util.TypeName getValueType()
      Returns the name that describes the type of parameter values. This is closely related to the Class returned by getValueClass():
      • If the value class is a collection (e.g. List or array), then this method returns the type of elements in the collection.
      • Otherwise this method returns the value class using the mapping documented in DefaultTypeName javadoc.
      TypeName is used for encoding parameters in XML or JSON documents, while getValueClass() is used for programmatic purposes.
      Returns:
      the type name of value component(s) in this parameter.
      Since:
      1.3
    • getValueClass

      public final Class<T> getValueClass()
      Returns the class that describes the type of parameter values.
      Specified by:
      getValueClass in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      the parameter value class.
    • getValidValues

      public Set<T> getValidValues()
      If this parameter allows only a finite set of values, returns that set. The set of valid values is usually a code list or enumeration. This method returns null if this parameter does not limit values to a finite set.
      Specified by:
      getValidValues in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      a finite set of valid values (usually from a code list), or null if it does not apply or if there is no restriction.
    • getValueDomain

      public final Range<?> getValueDomain()
      Returns the domain of values with their unit of measurement (if any), or null if none. The Range object combines the value class, minimum value, maximum value and whether these values are inclusive or inclusive. If the range is an instance of MeasurementRange, then it also contains the unit of measurement.
      API note: If this method returns a non-null value, then its type is either exactly Range<T>, or Range<E> where <E> is the component type of <T> (using wrapper classes for primitive types).
      Returns:
      the domain of values, or null.
      See Also:
    • getMinimumValue

      public Comparable<T> getMinimumValue()
      Returns the minimum parameter value. If there is no minimum value, or if minimum value is inappropriate for the value class, then this method returns null.

      This is a convenience method for getValueDomain().getMinValue(). Note that this method said nothing about whether the value is inclusive.

      Specified by:
      getMinimumValue in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      the minimum parameter value (often an instance of Double), or null if unbounded.
    • getMaximumValue

      public Comparable<T> getMaximumValue()
      Returns the maximum parameter value. If there is no maximum value, or if maximum value is inappropriate for the value type, then this method returns null.

      This is a convenience method for getValueDomain().getMaxValue(). Note that this method said nothing about whether the value is inclusive.

      Specified by:
      getMaximumValue in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      the minimum parameter value (often an instance of Double), or null if unbounded.
    • getDefaultValue

      public T getDefaultValue()
      Returns the default value for the parameter. The return type can be any type including a Number or a String. If there is no default value, then this method returns null.
      Specified by:
      getDefaultValue in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      the default value, or null in none.
    • getUnit

      public javax.measure.Unit<?> getUnit()
      Returns the unit of measurement for the minimum, maximum and default values. This attribute apply only if the values is of numeric type (usually an instance of Double).

      This is a convenience method for getValueDomain().unit().

      Specified by:
      getUnit in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      the unit for numeric value, or null if it doesn't apply to the value type.
    • createValue

      public org.opengis.parameter.ParameterValue<T> createValue()
      Creates a new parameter value instance initialized with the default value. The parameter descriptor for the created parameter value will be this object.
      Specified by:
      createValue in interface org.opengis.parameter.GeneralParameterDescriptor
      Specified by:
      createValue in interface org.opengis.parameter.ParameterDescriptor<T>
      Returns:
      a parameter initialized to the default value.
    • equals

      public boolean equals(Object object, ComparisonMode mode)
      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: All other properties (minimum and maximum occurrences, minimum, maximum and valid values) are compared only for modes stricter than ComparisonMode.IGNORE_METADATA.
      Specified by:
      equals in interface LenientComparable
      Overrides:
      equals in class AbstractParameterDescriptor
      Parameters:
      object - the object to compare to this.
      mode - the strictness level of the comparison.
      Returns:
      true if both objects are equal according the given comparison mode.
      See Also:
    • computeHashCode

      protected long computeHashCode()
      Invoked by AbstractIdentifiedObject.hashCode() for computing the hash code when first needed.
      Overrides:
      computeHashCode in class AbstractIdentifiedObject
      Returns:
      the hash code value. This value may change in any future Apache SIS version.
    • setValueClass

      final void setValueClass(DefaultParameterValue<?> param)
      Invoked by DefaultParameterValue when the descriptor is set after the value at unmarshalling time. There is two scenarios in a valid GML document. The first scenario is when the descriptor is defined inside the parameter value element, like below. In such case, valueClass is defined at construction time by DefaultParameterDescriptor() because the value is before the descriptor. In the second scenario shows below, the descriptor was defined before the value and is referenced by a link. In that case, valueClass is null the first time that this method is invoked. It may become non-null if the same parameter descriptor is reused for many parameter values. This method modifies the state of this class despite the fact that it should be immutable. It is okay because we are updating an instance created during GML unmarshalling, and that instance should not have been given to user yet.
      Parameters:
      param - the parameter value from which to infer the value type.