Package org.apache.sis.parameter
Class DefaultParameterDescriptor<T>
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.AbstractIdentifiedObject
org.apache.sis.parameter.AbstractParameterDescriptor
org.apache.sis.parameter.DefaultParameterDescriptor<T>
- Type Parameters:
T
- the type of elements to be returned byDefaultParameterValue.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:
- The parameter name.
- The class of values. This is usually
Double
,double[]
,Integer
,int[]
,Boolean
,String
orURI
, but other types are allowed as well. - Whether this parameter is optional or mandatory. This is specified by the minimum occurences number, which can be 0 or 1 respectively.
- The domain of values, as a minimum value, maximum value or an enumeration of valid values.
- The default value.
- The unit of measurement.
- Since:
- 0.4
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final T
The default value for the parameter, ornull
.private static final long
Serial number for inter-operability with different versions.A set of valid values (usually from a code list) ornull
if it does not apply.The class that describe the type of parameter values.private Range
<?> The minimum and maximum parameter value with their unit of measurement, ornull
if none.Fields inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
DEPRECATED_KEY, LOCALE_KEY
Fields inherited from interface org.opengis.referencing.IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Constructs a new object in which attributes may be set to a null value.DefaultParameterDescriptor
(Map<String, ?> properties, int minimumOccurs, int maximumOccurs, Class<T> valueClass, Range<?> valueDomain, T[] validValues, T defaultValue) Constructs a descriptor from the given properties.protected
DefaultParameterDescriptor
(org.opengis.parameter.ParameterDescriptor<T> descriptor) Creates a new descriptor with the same values than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DefaultParameterDescriptor
<T> castOrCopy
(org.opengis.parameter.ParameterDescriptor<T> object) Returns a SIS parameter implementation with the same values than the given arbitrary implementation.protected long
Invoked byAbstractIdentifiedObject.hashCode()
for computing the hash code when first needed.org.opengis.parameter.ParameterValue
<T> Creates a new parameter value instance initialized with the default value.boolean
equals
(Object object, ComparisonMode mode) Compares the specified object with this parameter for equality.Returns the default value for the parameter.Returns the GeoAPI interface implemented by this class.Returns the maximum parameter value.Returns the minimum parameter value.javax.measure.Unit
<?> getUnit()
If this parameter allows only a finite set of values, returns that set.Returns the class that describes the type of parameter values.final Range
<?> Returns the domain of values with their unit of measurement (if any), ornull
if none.org.opengis.util.TypeName
Returns the name that describes the type of parameter values.(package private) final void
setValueClass
(DefaultParameterValue<?> param) Invoked byDefaultParameterValue
when the descriptor is set after the value at unmarshalling time.Methods inherited from class org.apache.sis.parameter.AbstractParameterDescriptor
formatTo, getMaximumOccurs, getMinimumOccurs, print, toString
Methods inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
castOrCopy, equals, formatTo, getAlias, getDescription, getIdentifiers, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForName
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
toString, toWKT
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.parameter.GeneralParameterDescriptor
getMaximumOccurs, getMinimumOccurs
Methods inherited from interface org.opengis.referencing.IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
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
A set of valid values (usually from a code list) ornull
if it does not apply. This set is immutable.- See Also:
-
valueDomain
The minimum and maximum parameter value with their unit of measurement, ornull
if none. If this field is non-null, thenvalueDomain.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 ofvalueClass.getComponentType()
.
- See Also:
- If
-
defaultValue
The default value for the parameter, ornull
.- 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
orString
AbstractIdentifiedObject.getName()
"alias" GenericName
orCharSequence
(optionally as array)AbstractIdentifiedObject.getAlias()
"identifiers" ReferenceIdentifier
(optionally as array)AbstractIdentifiedObject.getIdentifiers()
"description" InternationalString
orString
AbstractIdentifiedObject.getDescription()
"remarks" InternationalString
orString
AbstractIdentifiedObject.getRemarks()
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:- The range shall be non-empty.
valueDomain.getElementType()
shall be equal to one of the following:- to
valueClass
if the latter is not an array, - or to
primitiveToWrapper(valueClass.getComponentType())
ifvalueClass
is an array.
- to
valueDomain
andvalidValues
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, orInteger.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, ornull
if none.validValues
- the list of valid values, ornull
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, ornull
if none.
-
DefaultParameterDescriptor
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 isnull
, then this method returnsnull
. 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, ornull
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
Returns the GeoAPI interface implemented by this class. The SIS implementation returnsParameterDescriptor.class
.Note for implementers: Subclasses usually do not need to override this method since GeoAPI does not defineParameterDescriptor
sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their own set of interfaces.- Overrides:
getInterface
in classAbstractParameterDescriptor
- 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 theClass
returned bygetValueClass()
:- 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, whilegetValueClass()
is used for programmatic purposes.- Returns:
- the type name of value component(s) in this parameter.
- Since:
- 1.3
- If the value class is a collection (e.g.
-
getValueClass
Returns the class that describes the type of parameter values.- Specified by:
getValueClass
in interfaceorg.opengis.parameter.ParameterDescriptor<T>
- Returns:
- the parameter value class.
-
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 returnsnull
if this parameter does not limit values to a finite set.- Specified by:
getValidValues
in interfaceorg.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
Returns the domain of values with their unit of measurement (if any), ornull
if none. TheRange
object combines the value class, minimum value, maximum value and whether these values are inclusive or inclusive. If the range is an instance ofMeasurementRange
, then it also contains the unit of measurement.API note: If this method returns a non-null value, then its type is either exactlyRange<T>
, orRange<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
Returns the minimum parameter value. If there is no minimum value, or if minimum value is inappropriate for the value class, then this method returnsnull
.This is a convenience method for
getValueDomain().getMinValue()
. Note that this method said nothing about whether the value is inclusive. -
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 returnsnull
.This is a convenience method for
getValueDomain().getMaxValue()
. Note that this method said nothing about whether the value is inclusive. -
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 interfaceorg.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 ofDouble
).This is a convenience method for
getValueDomain().unit()
.- Specified by:
getUnit
in interfaceorg.opengis.parameter.ParameterDescriptor<T>
- Returns:
- the unit for numeric value, or
null
if it doesn't apply to the value type.
-
createValue
Creates a new parameter value instance initialized with the default value. The parameter descriptor for the created parameter value will bethis
object.- Specified by:
createValue
in interfaceorg.opengis.parameter.GeneralParameterDescriptor
- Specified by:
createValue
in interfaceorg.opengis.parameter.ParameterDescriptor<T>
- Returns:
- a parameter initialized to the default value.
-
equals
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:AbstractIdentifiedObject.getName()
, compared heuristically inIGNORE_METADATA
or less strict mode.getValueClass()
getDefaultValue()
getUnit()
ComparisonMode.IGNORE_METADATA
.- Specified by:
equals
in interfaceLenientComparable
- Overrides:
equals
in classAbstractParameterDescriptor
- Parameters:
object
- the object to compare tothis
.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 byAbstractIdentifiedObject.hashCode()
for computing the hash code when first needed.- Overrides:
computeHashCode
in classAbstractIdentifiedObject
- Returns:
- the hash code value. This value may change in any future Apache SIS version.
-
setValueClass
Invoked byDefaultParameterValue
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 byDefaultParameterDescriptor()
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
isnull
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.
-