Package org.geotools.parameter
Class DefaultParameterDescriptor<T>
- Object
-
- Formattable
-
- AbstractIdentifiedObject
-
- AbstractParameterDescriptor
-
- DefaultParameterDescriptor<T>
-
- Type Parameters:
T
- The type of elements to be returned byParameterValue.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
-
-
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
Constructors Constructor Description DefaultParameterDescriptor(String name, Class<T> valueClass, T[] validValues, T defaultValue)
Constructs a mandatory parameter for a set of predefined values.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(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(ParameterDescriptor<T> descriptor)
Constructs a descriptor with the same values than the specified one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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(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.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()
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
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
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.geotools.api.util.CodeList code list}) ornull
if it doesn't apply.defaultValue
- The default value for the parameter, ornull
.
-
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.geotools.api.util.CodeList code list}) ornull
if it doesn't apply.defaultValue
- The default value for the parameter, ornull
.minimum
- The minimum parameter value, ornull
.maximum
- The maximum parameter value, ornull
.unit
- The unit for default, minimum and maximum values.required
-true
if this parameter is required, orfalse
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.geotools.api.util.CodeList code list}) ornull
if it doesn't apply.defaultValue
- The default value for the parameter, ornull
.minimum
- The minimum parameter value, ornull
.maximum
- The maximum parameter value, ornull
.unit
- The unit for default, minimum and maximum values.required
-true
if this parameter is required, orfalse
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, orInteger.MIN_VALUE
if none.maximum
- The maximum parameter value, orInteger.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, orInteger.MIN_VALUE
if none.maximum
- The maximum parameter value, orInteger.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, orDouble.NaN
if none.minimum
- The minimum parameter value, orDouble.NEGATIVE_INFINITY
if none.maximum
- The maximum parameter value, orDouble.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, orDouble.NaN
if none.minimum
- The minimum parameter value, orDouble.NEGATIVE_INFINITY
if none.maximum
- The maximum parameter value, orDouble.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 aString
or anInternationalString
.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 interfaceGeneralParameterDescriptor
- Specified by:
getMaximumOccurs
in classAbstractParameterDescriptor
- 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 bethis
object.- Specified by:
createValue
in interfaceGeneralParameterDescriptor
- Specified by:
createValue
in interfaceParameterDescriptor<T>
- Specified by:
createValue
in classAbstractParameterDescriptor
- 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 interfaceParameterDescriptor<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.geotools.api.util.CodeList code list} or enumerations. This method returnsnull
if this parameter doesn't limits values to a finite set.- Specified by:
getValidValues
in interfaceParameterDescriptor<T>
- Returns:
- A finite set of valid values (usually from a {linkplain
org.geotools.api.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 aNumber
or aString
. If there is no default value, then this method returnsnull
.- Specified by:
getDefaultValue
in interfaceParameterDescriptor<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 returnsnull
.- Specified by:
getMinimumValue
in interfaceParameterDescriptor<T>
- Returns:
- The minimum parameter value (often an instance of
Double
), ornull
.
-
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 returnsnull
.- Specified by:
getMaximumValue
in interfaceParameterDescriptor<T>
- Returns:
- The minimum parameter value (often an instance of
Double
), ornull
.
-
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 ofDouble
).- Specified by:
getUnit
in interfaceParameterDescriptor<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 classAbstractParameterDescriptor
- Parameters:
object
- The object to compare tothis
.compareMetadata
-true
for performing a strict comparaison, orfalse
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 classAbstractParameterDescriptor
- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
-