org.geotoolkit.parameter
Class DefaultParameterDescriptor<T>

Object
  extended by FormattableObject
      extended by AbstractIdentifiedObject
          extended by AbstractParameterDescriptor
              extended by DefaultParameterDescriptor<T>
Type Parameters:
T - The type of elements to be returned by ParameterValue.getValue().
All Implemented Interfaces:
Serializable, Formattable, LenientComparable, GeneralParameterDescriptor, ParameterDescriptor<T>, IdentifiedObject

@Immutable
public class DefaultParameterDescriptor<T>
extends AbstractParameterDescriptor
implements ParameterDescriptor<T>

The definition of a parameter used by an operation method. For Coordinate Reference Systems most parameter values are numeric, but other types of parameter values are possible.

For numeric values, the value class is usually Double, Integer or some other Java wrapper class.

This class contains numerous convenience constructors. But all of them ultimately invoke a single, full-featured constructor. All other constructors are just shortcuts.

Since:
2.0
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys), Johann Sorel (Geomatys)
See Also:
Parameter, DefaultParameterDescriptorGroup, Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
 
Constructor Summary
DefaultParameterDescriptor(Citation authority, String name, Class<T> valueClass, T[] validValues, T defaultValue, Comparable<T> minimum, Comparable<T> maximum, Unit<?> unit, boolean required)
          Constructs a descriptor from an authority and a name.
DefaultParameterDescriptor(Map<String,?> properties, Class<T> valueClass, T[] validValues, T defaultValue, Comparable<T> minimum, Comparable<T> maximum, Unit<?> unit, boolean required)
          Constructs a descriptor from a set of properties.
DefaultParameterDescriptor(ParameterDescriptor<T> descriptor)
          Constructs a descriptor with the same values than the specified one.
DefaultParameterDescriptor(String name, CharSequence remarks, Class<T> valueClass, T defaultValue, boolean required)
          Constructs a descriptor from a name and a default value.
DefaultParameterDescriptor(String name, Class<T> valueClass, T[] validValues, T defaultValue)
          Constructs a descriptor for a mandatory parameter having a set of valid values.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this identified object.
static DefaultParameterDescriptor<Double> create(Map<String,?> properties, double defaultValue, double minimum, double maximum, Unit<?> unit, boolean required)
          Constructs a descriptor for a parameter in a range of floating point values.
static DefaultParameterDescriptor<Integer> create(Map<String,?> properties, int defaultValue, int minimum, int maximum, boolean required)
          Constructs a descriptor for a parameter in a range of integer values.
static DefaultParameterDescriptor<Double> create(String name, double defaultValue, double minimum, double maximum, Unit<?> unit)
          Constructs a descriptor for a mandatory parameter in a range of floating point values.
static DefaultParameterDescriptor<Integer> create(String name, int defaultValue, int minimum, int maximum)
          Constructs a descriptor for a mandatory parameter in a range of integer values.
 ParameterValue<T> createValue()
          Creates a new instance of ParameterValue initialized with the default value.
 boolean equals(Object object, ComparisonMode mode)
          Compares the specified object with this parameter for equality.
 T getDefaultValue()
          Returns the default value for the parameter.
 int getMaximumOccurs()
          The maximum number of times that values for this parameter group or parameter can be included.
 Comparable<T> getMaximumValue()
          Returns the maximum parameter value.
 Comparable<T> getMinimumValue()
          Returns the minimum parameter value.
 Unit<?> getUnit()
          Returns the unit for default, minimum and maximum values.
 Set<T> getValidValues()
          If this parameter allows only a finite set of values, returns this set.
 Class<T> getValueClass()
          Returns the class that describe the type of the parameter.
 String toString()
          Returns a string representation of this descriptor.
 
Methods inherited from class AbstractParameterDescriptor
formatWKT, getMinimumOccurs
 
Methods inherited from class AbstractIdentifiedObject
equals, getAlias, getIdentifier, getIdentifiers, getName, getName, getRemarks, hashCode, nameMatches
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface GeneralParameterDescriptor
getMinimumOccurs
 
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
 

Constructor Detail

DefaultParameterDescriptor

public DefaultParameterDescriptor(ParameterDescriptor<T> descriptor)
Constructs a descriptor with the same values than the specified one. This copy constructor can be used in order to wrap an arbitrary implementation into a Geotk one.

Parameters:
descriptor - The descriptor to copy.
Since:
2.2

DefaultParameterDescriptor

public DefaultParameterDescriptor(String name,
                                  Class<T> valueClass,
                                  T[] validValues,
                                  T defaultValue)
Constructs a descriptor for a mandatory parameter having a set of valid values. The descriptor has no minimal or maximal value and no unit.

Parameters:
name - The parameter name.
valueClass - The class that describe the type of the parameter.
validValues - A finite set of valid values (usually from a code list) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null if none.

DefaultParameterDescriptor

public DefaultParameterDescriptor(Citation authority,
                                  String name,
                                  Class<T> valueClass,
                                  T[] validValues,
                                  T defaultValue,
                                  Comparable<T> minimum,
                                  Comparable<T> maximum,
                                  Unit<?> unit,
                                  boolean required)
Constructs a descriptor from an authority and a name.

Parameters:
authority - The authority (example: OGC).
name - The parameter name.
valueClass - The class that describes the type of the parameter value.
validValues - A finite set of valid values (usually from a code list) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null if none.
minimum - The minimum parameter value (inclusive), or null if none.
maximum - The maximum parameter value (inclusive), or null if none.
unit - The unit of measurement for the default, minimum and maximum values, or null if none.
required - true if this parameter is required, or false if it is optional.
Since:
2.2

DefaultParameterDescriptor

public DefaultParameterDescriptor(String name,
                                  CharSequence remarks,
                                  Class<T> valueClass,
                                  T defaultValue,
                                  boolean required)
Constructs a descriptor from a name and a default value.

Parameters:
name - The parameter name.
remarks - An optional description as a String or an InternationalString.
valueClass - The class that describe the type of the parameter.
defaultValue - The default value.
required - true if this parameter is required, false otherwise.
Since:
2.5

DefaultParameterDescriptor

public DefaultParameterDescriptor(Map<String,?> properties,
                                  Class<T> valueClass,
                                  T[] validValues,
                                  T defaultValue,
                                  Comparable<T> minimum,
                                  Comparable<T> maximum,
                                  Unit<?> unit,
                                  boolean required)
Constructs a descriptor from a set of properties. The properties map is given unchanged to the super-class constructor.

Parameters:
properties - Set of properties. Should contains at least "name".
valueClass - The class that describes the type of the parameter value.
validValues - A finite set of valid values (usually from a code list) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null if none.
minimum - The minimum parameter value (inclusive), or null if none.
maximum - The maximum parameter value (inclusive), or null if none.
unit - The unit of measurement for the default, minimum and maximum values, or null if none.
required - true if this parameter is required, or false if it is optional.
Method Detail

create

public static DefaultParameterDescriptor<Integer> create(String name,
                                                         int defaultValue,
                                                         int minimum,
                                                         int maximum)
Constructs a descriptor for a mandatory parameter in a range of integer values.

Parameters:
name - The parameter name.
defaultValue - The default value for the parameter.
minimum - The minimum parameter value, or Integer.MIN_VALUE if none.
maximum - The maximum parameter value, or Integer.MAX_VALUE if none.
Returns:
The parameter descriptor for the given range of values.
Since:
2.5

create

public static DefaultParameterDescriptor<Integer> create(Map<String,?> properties,
                                                         int defaultValue,
                                                         int minimum,
                                                         int maximum,
                                                         boolean required)
Constructs a descriptor for a parameter in a range of integer values.

Parameters:
properties - The parameter properties (name, identifiers, alias...).
defaultValue - The default value for the parameter.
minimum - The minimum parameter value, or Integer.MIN_VALUE if none.
maximum - The maximum parameter value, or Integer.MAX_VALUE if none.
required - true if this parameter is required, false otherwise.
Returns:
The parameter descriptor for the given range of values.
Since:
2.5

create

public static DefaultParameterDescriptor<Double> create(String name,
                                                        double defaultValue,
                                                        double minimum,
                                                        double maximum,
                                                        Unit<?> unit)
Constructs a descriptor for a mandatory parameter in a range of floating point values.

Parameters:
name - The parameter name.
defaultValue - The default value for the parameter, or Double.NaN if none.
minimum - The minimum parameter value, or Double.NEGATIVE_INFINITY if none.
maximum - The maximum parameter value, or Double.POSITIVE_INFINITY if none.
unit - The unit for default, minimum and maximum values.
Returns:
The parameter descriptor for the given range of values.
Since:
2.5

create

public static DefaultParameterDescriptor<Double> create(Map<String,?> properties,
                                                        double defaultValue,
                                                        double minimum,
                                                        double maximum,
                                                        Unit<?> unit,
                                                        boolean required)
Constructs a descriptor for a parameter in a range of floating point values.

Parameters:
properties - The parameter properties (name, identifiers, alias...).
defaultValue - The default value for the parameter, or Double.NaN if none.
minimum - The minimum parameter value, or Double.NEGATIVE_INFINITY if none.
maximum - The maximum parameter value, or Double.POSITIVE_INFINITY if none.
unit - The unit of measurement for default, minimum and maximum values.
required - true if this parameter is required, false otherwise.
Returns:
The parameter descriptor for the given range of values.
Since:
2.5

getMaximumOccurs

public int getMaximumOccurs()
The maximum number of times that values for this parameter group or parameter can be included. For a single parameter, the value is always 1.

Specified by:
getMaximumOccurs in interface GeneralParameterDescriptor
Specified by:
getMaximumOccurs in class AbstractParameterDescriptor
Returns:
The maximum occurrence.
See Also:
AbstractParameterDescriptor.getMinimumOccurs()

createValue

public ParameterValue<T> createValue()
Creates a new instance of ParameterValue initialized with the default value. The parameter descriptor for the created parameter value will be this object.

Specified by:
createValue in interface GeneralParameterDescriptor
Specified by:
createValue in interface ParameterDescriptor<T>
Specified by:
createValue in class AbstractParameterDescriptor
Returns:
A parameter initialized to the default value.

getValueClass

public Class<T> getValueClass()
Returns the class that describe the type of the parameter.

Specified by:
getValueClass in interface ParameterDescriptor<T>
Returns:
The parameter value class.

getValidValues

public Set<T> getValidValues()
If this parameter allows only a finite set of values, returns this set. This set is usually a code list or enumerations. This method returns null if this parameter doesn't limits values to a finite set.

Specified by:
getValidValues in interface ParameterDescriptor<T>
Returns:
A finite set of valid values (usually from a code list), or null if it doesn't apply.

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 ParameterDescriptor<T>
Returns:
The default value, or null in none.

getMinimumValue

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

Specified by:
getMinimumValue in interface ParameterDescriptor<T>
Returns:
The minimum parameter value (often an instance of Double), or null.

getMaximumValue

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

Specified by:
getMaximumValue in interface ParameterDescriptor<T>
Returns:
The minimum parameter value (often an instance of Double), or null.

getUnit

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

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

equals

public boolean equals(Object object,
                      ComparisonMode mode)
Compares the specified object with this parameter for equality.

Specified by:
equals in interface LenientComparable
Overrides:
equals in class AbstractParameterDescriptor
Parameters:
object - The object to compare to this.
mode - STRICT for performing a strict comparison, or IGNORE_METADATA for comparing only properties relevant to transformations.
Returns:
true if both objects are equal.

computeHashCode

protected int computeHashCode()
Computes a hash value for this identified object. This method is invoked by AbstractIdentifiedObject.hashCode() when first needed.

Implementation specific feature
In the Geotk implementation, the name, identifiers and remarks are not used for hash code computation. Consequently two identified objects will return the same hash value if they are equal in the sense of equals(…, ComparisonMode.IGNORE_METADATA). This feature allows users to implement metadata-insensitive HashMap.

Overrides:
computeHashCode in class AbstractParameterDescriptor
Returns:
The hash code value. This value may change between different execution of the Geotk library.

toString

public String toString()
Returns a string representation of this descriptor. The string returned by this method is for information purpose only and may change in future version.

Overrides:
toString in class FormattableObject
Since:
3.17


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.