public abstract class Parameters extends Object implements ParameterValueGroup, Cloneable
DefaultParameterValueGroup
javadoc for a description of the standard way to get and set a particular
parameter in a group. The remaining of this javadoc is specific to Apache SIS.
cast(…, Class)
for type safety with parameterized types.getMemberName(ParameterDescriptor)
for inter-operability between ISO 19111 and ISO 19115.getValueDomain(ParameterDescriptor)
for information purpose.copy(ParameterValueGroup, ParameterValueGroup)
for copying values into an existing instance.ParameterValueGroup.parameter(String)
method.
This Parameters
class provides an alternative way, using a ParameterDescriptor
argument
instead than a String
. The methods in this class use the additional information provided by the
descriptor for choosing a String
argument that the above-cited parameter(String)
method
is more likely to know (by giving preference to a name
or alias defined by a common
authority),
and for applying type and unit conversions.
"semi_major"
.
But that parameter can also be named "semi_major_axis"
, "earth_radius"
or simply "a"
in other libraries. When fetching parameter values, we do not always know in advance which of the above-cited
names is recognized by an arbitrary ParameterValueGroup
implementation.
This uncertainty is mitigated with the Apache SIS implementation since
DefaultParameterValueGroup.parameter(String)
compares the given String
argument
against all parameter's aliases in addition
to the name.
However we do not have the guarantee that all implementations do that.
ParameterValue
interface.
Those methods are themselves inspired by JDK methods:
Parameters method | ParameterValue method | JDK methods |
---|---|---|
getValue(ParameterDescriptor) | getValue() | |
booleanValue(ParameterDescriptor) | booleanValue() | Boolean.booleanValue() |
intValue(ParameterDescriptor) | intValue() | Number.intValue() |
intValueList(ParameterDescriptor) | intValueList() | |
doubleValue(ParameterDescriptor) | doubleValue() | Number.doubleValue() |
doubleValueList(ParameterDescriptor) | doubleValueList() | |
stringValue(ParameterDescriptor) | stringValue() |
ParameterValueGroup
methods.
In addition, each method in this class is isolated from all others: overriding one method has
no impact on other methods.
ParameterValueGroup
interface, this class is not named
AbstractParameterValueGroup
because it does not implement any method from the interface.
Extending this class or extending Object
make almost no difference for implementors.
The intend of this Parameters
class is rather to extend the API with methods
that are convenient for the way Apache SIS uses parameters.
In other words, this class is intended for users rather than implementors.Defined in the sis-referencing
module
Modifier | Constructor and Description |
---|---|
protected |
Parameters()
For subclass constructors only.
|
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue(ParameterDescriptor<Boolean> parameter)
Returns the boolean value of the parameter identified by the given descriptor.
|
static <T> ParameterDescriptor<T> |
cast(ParameterDescriptor<?> descriptor,
Class<T> valueClass)
Casts the given parameter descriptor to the given type.
|
static <T> ParameterValue<T> |
cast(ParameterValue<?> parameter,
Class<T> valueClass)
Casts the given parameter value to the given type.
|
static Parameters |
castOrWrap(ParameterValueGroup parameters)
Returns the given parameter value group as a
Parameters instance. |
Parameters |
clone()
Returns a copy of this group of parameter values.
|
static void |
copy(ParameterValueGroup values,
ParameterValueGroup destination)
Copies the values of a parameter group into another parameter group.
|
double |
doubleValue(ParameterDescriptor<? extends Number> parameter)
Returns the floating point value of the parameter identified by the given descriptor.
|
double[] |
doubleValueList(ParameterDescriptor<double[]> parameter)
Returns the floating point values of the parameter identified by the given descriptor.
|
static GeneralParameterDescriptor[] |
getDescriptors(GeneralParameterValue... parameters)
Returns the descriptors of the given parameters, in the same order.
|
static MemberName |
getMemberName(ParameterDescriptor<?> parameter)
Gets the parameter name as an instance of
MemberName . |
<T> ParameterValue<T> |
getOrCreate(ParameterDescriptor<T> parameter)
Returns the parameter identified by the given descriptor.
|
<T> T |
getValue(ParameterDescriptor<T> parameter)
Returns the value of the parameter identified by the given descriptor.
|
static Range<?> |
getValueDomain(ParameterDescriptor<?> descriptor)
Returns the domain of valid values defined by the given descriptor, or
null if none. |
int |
intValue(ParameterDescriptor<? extends Number> parameter)
Returns the integer value of the parameter identified by the given descriptor.
|
int[] |
intValueList(ParameterDescriptor<int[]> parameter)
Returns the integer values of the parameter identified by the given descriptor.
|
String |
stringValue(ParameterDescriptor<? extends CharSequence> parameter)
Returns the string value of the parameter identified by the given descriptor.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addGroup, getDescriptor, groups, parameter, values
public static Parameters castOrWrap(ParameterValueGroup parameters)
Parameters
instance.
If the given parameters is already an instance of Parameters
, then it is returned as-is.
Otherwise this method returns a wrapper which delegate all method invocations to the given instance.
This method provides a way to get access to the non-static Parameters
methods, like
getValue(ParameterDescriptor)
, for an arbitrary ParameterValueGroup
instance.
parameters
- The object to cast or wrap, or null
.Parameters
(may be the same reference),
or null
if the given argument was null.public static <T> ParameterDescriptor<T> cast(ParameterDescriptor<?> descriptor, Class<T> valueClass) throws ClassCastException
T
- The expected value class.descriptor
- The descriptor to cast, or null
.valueClass
- The expected value class.null
if the given descriptor was null.ClassCastException
- if the given descriptor does not have the expected value class.Class.cast(Object)
public static <T> ParameterValue<T> cast(ParameterValue<?> parameter, Class<T> valueClass) throws ClassCastException
T
- The expected value class.parameter
- The parameter to cast, or null
.valueClass
- The expected value class.null
if the given value was null.ClassCastException
- if the given value doesn't have the expected value class.Class.cast(Object)
public static GeneralParameterDescriptor[] getDescriptors(GeneralParameterValue... parameters)
null
, then this method returns null
.
null
, then the corresponding
element of the returned array is also null
.parameters
- The parameter values from which to get the descriptors, or null
.null
if the parameters
argument was null.public static MemberName getMemberName(ParameterDescriptor<?> parameter)
MemberName
.
This method performs the following checks:
MemberName
,
returns that primary name.MemberName
. If found, that alias is returned.DefaultTypeName
javadoc.CC_OperationParameter
) and the one
defined by ISO 19115 (namely SV_Parameter
).parameter
- The parameter from which to get the name (may be null
).null
if none.Names.createMemberName(CharSequence, String, CharSequence, Class)
public static Range<?> getValueDomain(ParameterDescriptor<?> descriptor)
null
if none.
This method performs the following operations:
DefaultParameterDescriptor
,
delegate to DefaultParameterDescriptor.getValueDomain()
.descriptor
- The parameter descriptor, or null
.null
if none.DefaultParameterDescriptor.getValueDomain()
public <T> T getValue(ParameterDescriptor<T> parameter) throws ParameterNotFoundException
parameter
descriptor:
ParameterValueGroup
, chosen as below:
ParameterDescriptor
are known in advance, for example in the
implementation of some coordinate
operation method. If the caller has no such ParameterDescriptor
at hand, then the
parameter(String)
method is probably more convenient.T
- The type of the parameter value.parameter
- The name or alias of the parameter to look for, together with the desired type and unit of value.null
).ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.DefaultParameterValueGroup.parameter(String)
,
DefaultParameterValue.getValue()
public boolean booleanValue(ParameterDescriptor<Boolean> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.booleanValue()
public int intValue(ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.intValue()
public int[] intValueList(ParameterDescriptor<int[]> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.intValueList()
public double doubleValue(ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this method
uses the given parameter
argument.
If the given descriptor supplies a unit of measurement, then the returned value will be converted into that unit.
parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.doubleValue(Unit)
public double[] doubleValueList(ParameterDescriptor<double[]> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this method
uses the given parameter
argument.
If the given descriptor supplies a unit of measurement, then the returned values will be converted into that unit.
parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.doubleValueList(Unit)
public String stringValue(ParameterDescriptor<? extends CharSequence> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- The name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.stringValue()
public <T> ParameterValue<T> getOrCreate(ParameterDescriptor<T> parameter) throws ParameterNotFoundException
The default implementation is equivalent to:
wherereturn cast(parameter(name), parameter.getValueClass());
name
is a parameter
name
or alias chosen by the same algorithm than
getValue(ParameterDescriptor)
.T
- The type of the parameter value.parameter
- The parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.DefaultParameterValueGroup.parameter(String)
public Parameters clone()
clone
in interface GeneralParameterValue
clone
in interface ParameterValueGroup
clone
in class Object
copy(ParameterValueGroup, ParameterValueGroup)
public static void copy(ParameterValueGroup values, ParameterValueGroup destination) throws InvalidParameterNameException, InvalidParameterValueException
source
group shall be valid for the destination
group,
but the destination
may have more parameters.
Sub-groups are copied recursively.
A typical usage of this method is for transferring values from an arbitrary implementation to some specific implementation, or to a parameter group using a different but compatible descriptor.
values
- The parameters values to copy.destination
- Where to copy the values.InvalidParameterNameException
- if a source
parameter name is unknown to the destination
.InvalidParameterValueException
- if the value of a source
parameter is invalid for the destination
.clone()
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.