org.geotools.parameter
Class DefaultParameterDescriptor<T>

Object
  extended by Formattable
      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, GeneralParameterDescriptor, ParameterDescriptor<T>, IdentifiedObject

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.class, Integer.class 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.1
Author:
Martin Desruisseaux (IRD)
See Also:
Parameter, DefaultParameterDescriptorGroup, Serialized Form
Module:
modules/library/referencing (gt-referencing.jar)

Field Summary
 
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
 
Fields inherited from class Formattable
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 parameter 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 parameter from a set of properties.
DefaultParameterDescriptor(ParameterDescriptor<T> descriptor)
          Constructs a descriptor with the same values than the specified one.
DefaultParameterDescriptor(String name, Class<T> valueClass, T[] validValues, T defaultValue)
          Constructs a mandatory parameter for a set of predefined values.
 
Method Summary
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
<T> DefaultParameterDescriptor<T>
create(String name, CharSequence remarks, Class<T> valueClass, T defaultValue, boolean required)
          Constructs a descriptor from a name and a default value.
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 parameter value initialized with the default value.
 boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
          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.
 int hashCode()
          Returns a hash value for this parameter.
 
Methods inherited from class AbstractParameterDescriptor
formatWKT, getMinimumOccurs
 
Methods inherited from class AbstractIdentifiedObject
asSet, ensureAngularUnit, ensureLinearUnit, ensureNonNull, ensureNonNull, ensureTimeUnit, equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, nameMatches, nameMatches, nameMatches
 
Methods inherited from class Formattable
toString, 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 may be used in order to wraps an arbitrary implementation into a Geotools one.

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

DefaultParameterDescriptor

public DefaultParameterDescriptor(String name,
                                  Class<T> valueClass,
                                  T[] validValues,
                                  T defaultValue)
Constructs a mandatory parameter for a set of predefined values.

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 {linkplain org.opengis.util.CodeList code list}) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null.

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 parameter from an authority and a name.

Parameters:
authority - The authority (e.g. OGC).
name - The parameter name.
valueClass - The class that describe the type of the parameter.
validValues - A finite set of valid values (usually from a {linkplain org.opengis.util.CodeList code list}) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null.
minimum - The minimum parameter value, or null.
maximum - The maximum parameter value, or null.
unit - The unit for default, minimum and maximum values.
required - true if this parameter is required, or false if it is optional.
Since:
2.2

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 parameter 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 describe the type of the parameter.
validValues - A finite set of valid values (usually from a {linkplain org.opengis.util.CodeList code list}) or null if it doesn't apply.
defaultValue - The default value for the parameter, or null.
minimum - The minimum parameter value, or null.
maximum - The maximum parameter value, or null.
unit - The unit for default, minimum and maximum values.
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

create

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

Type Parameters:
T - The parameter type.
Parameters:
name - The parameter name.
remarks - An optional description as a String or an InternationalString.
valueClass - The parameter type.
defaultValue - The default value.
required - true if this parameter is required, false otherwise.
Returns:
The parameter descriptor for the given default value.
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 occurence.
See Also:
AbstractParameterDescriptor.getMinimumOccurs()

createValue

public ParameterValue<T> createValue()
Creates a new instance of parameter value initialized with the default value. The parameter value 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 {linkplain org.opengis.util.CodeList 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 {linkplain org.opengis.util.CodeList 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(AbstractIdentifiedObject object,
                      boolean compareMetadata)
Compares the specified object with this parameter for equality.

Overrides:
equals in class AbstractParameterDescriptor
Parameters:
object - The object to compare to this.
compareMetadata - true for performing a strict comparaison, or false for comparing only properties relevant to transformations.
Returns:
true if both objects are equal.

hashCode

public int hashCode()
Returns a hash value for this parameter.

Overrides:
hashCode in class AbstractParameterDescriptor
Returns:
The hash code value. This value doesn't need to be the same in past or future versions of this class.


Copyright © 1996-2009 Geotools. All Rights Reserved.