public class DefaultParameterValueGroup extends Parameters implements LenientComparable, Serializable
java.util.Map
:
parameter(String)
is similar in purpose to Map.get(Object)
,
with an additional level of indirection in both the argument and the return value.values()
is similar in purpose to Map.entrySet()
,
with ParameterValue
playing a role similar to Map.Entry
.ParameterValueGroup
instances are typically created by calls to
descriptor.createValue()
on a descriptor
supplied by a coordinate operation or process provider. New instances are initialized with a list of values containing all mandatory parameters, and no optional parameter. The values list is modifiable, but
all methods will first ensure that the modification would not violate the cardinality constraints (i.e. the minimum
and maximum occurrences of that parameter allowed by the descriptor). If a cardinality constraint is violated, then
an InvalidParameterCardinalityException
will be thrown.
ParameterValueGroup
instance has been created, the parameter values can be set by chaining
calls to parameter(String)
with one of the setValue(…)
methods defined in the returned object
(see the table of setter methods). The parameter(String)
method can
be invoked regardless of whether the parameter is mandatory or optional: if the parameter was optional and not
yet present in this group, it will be created.
DefaultParameterDescriptorGroup
example,
one can set Mercator (variant A) projection parameters as below:
ParameterValueGroup mercator = Mercator.PARAMETERS.createValue(); mercator.parameter("Longitude of natural origin").setValue(-60, Units.DEGREE); // 60°W mercator.parameter("Latitude of natural origin") .setValue( 40, Units.DEGREE); // 40°N // Keep default values for other parameters.
List.addAll(Collection)
method can been invoked on the values list.
ParameterValue<?>[] parameter = ...; // Defined elsewhere. ParameterValueGroup mercator = Mercator.PARAMETERS.createValue(); mercator.values().addAll(Arrays.asList(parameters));
List.remove(int)
or List.remove(Object)
operations on the values list. But attempts to remove a mandatory parameter will cause an
InvalidParameterCardinalityException
to be thrown.
Calls to values().clear()
restore this DefaultParameterValueGroup
to its initial state.
DefaultParameterDescriptorGroup
,
DefaultParameterValue
,
Serialized FormDefined in the sis-referencing
module
Constructor and Description |
---|
DefaultParameterValueGroup(ParameterDescriptorGroup descriptor)
Creates a parameter group from the specified descriptor.
|
DefaultParameterValueGroup(ParameterValueGroup parameters)
Creates a new instance initialized with all values from the specified parameter group.
|
Modifier and Type | Method and Description |
---|---|
ParameterValueGroup |
addGroup(String name)
Creates a new subgroup of the specified name, and adds it to the list of subgroups.
|
DefaultParameterValueGroup |
clone()
Returns a deep copy of this group of parameter values.
|
boolean |
equals(Object object)
Compares the specified object with this parameter for equality.
|
boolean |
equals(Object object,
ComparisonMode mode)
Compares the specified object with this parameter for equality.
|
ParameterDescriptorGroup |
getDescriptor()
Returns the abstract definition of this group of parameters.
|
List<ParameterValueGroup> |
groups(String name)
Returns all subgroups with the specified name.
|
int |
hashCode()
Returns a hash value for this parameter.
|
ParameterValue<?> |
parameter(String name)
Returns the value in this group for the specified name.
|
List<GeneralParameterValue> |
values()
Returns the values in this group.
|
booleanValue, cast, cast, castOrWrap, copy, doubleValue, doubleValueList, getDescriptors, getMandatoryValue, getMemberName, getOrCreate, getValue, getValueDomain, intValue, intValueList, print, stringValue, toString, unmodifiable
public DefaultParameterValueGroup(ParameterDescriptorGroup descriptor)
Usage note: ParameterValueGroup
are usually not instantiated directly. Instead, consider
invoking descriptor.createValue()
on a descriptor supplied by a map projection or process provider.
descriptor
- the descriptor for this group.public DefaultParameterValueGroup(ParameterValueGroup parameters)
parameters
- The parameters to copy values from.clone()
public ParameterDescriptorGroup getDescriptor()
getDescriptor
in interface GeneralParameterValue
getDescriptor
in interface ParameterValueGroup
public List<GeneralParameterValue> values()
ParameterValueGroup
, and conversely.
getDescriptor()
.InvalidParameterNameException
,
InvalidParameterCardinalityException
or other runtime exceptions if a condition
is not meet.values
in interface ParameterValueGroup
public ParameterValue<?> parameter(String name) throws ParameterNotFoundException
ParameterValue
instance is
created, added to this group and returned.ParameterNotFoundException
is thrown.double easting = parameter("False easting" ).doubleValue(); double northing = parameter("False northing").doubleValue(); parameter("False easting").setValue(500000.0);
parameters(String)
method
returning a list of parameter values because the ISO 19111 standard fixes the ParameterValue
maximum occurrence to 1.parameter
in interface ParameterValueGroup
name
- the name of the parameter to search for.ParameterNotFoundException
- if there is no parameter value for the given name.Parameters.getValue(ParameterDescriptor)
public List<ParameterValueGroup> groups(String name) throws ParameterNotFoundException
This method do not create new groups: if the requested group is optional (i.e.
minimumOccurs == 0
)
and no value were defined previously, then this method returns an empty set.
groups
in interface ParameterValueGroup
name
- the name of the parameter to search for.ParameterNotFoundException
- if no descriptor was found for the given name.public ParameterValueGroup addGroup(String name) throws ParameterNotFoundException, InvalidParameterCardinalityException
removeGroup(String)
method. To remove a group, users shall inspect the
values()
list, decide which occurrences to remove if there is many of them for the
same name, and whether to iterate recursively into sub-groups or not.addGroup
in interface ParameterValueGroup
name
- the name of the parameter group to create.ParameterNotFoundException
- if no descriptor was found for the given name.InvalidParameterCardinalityException
- if this parameter group already contains the
maximum number of occurrences
of subgroups of the given name.public boolean equals(Object object, ComparisonMode mode)
ComparisonMode.STRICT
and BY_CONTRACT
take in account the parameter order.ComparisonMode.IGNORE_METADATA
and APPROXIMATIVE
ignore the order of parameter values (but not necessarily the order of parameter descriptors).equals
in interface LenientComparable
object
- the object to compare to this
.mode
- the strictness level of the comparison.true
if both objects are equal according the given comparison mode.Utilities.deepEquals(Object, Object, ComparisonMode)
public final boolean equals(Object object)
return equals(other, ComparisonMode.STRICT);Subclasses shall override
equals(Object, ComparisonMode)
instead than this method.equals
in interface LenientComparable
equals
in class Object
object
- the object to compare to this
.true
if both objects are equal.ComparisonMode.STRICT
public int hashCode()
public DefaultParameterValueGroup clone()
clone
in interface GeneralParameterValue
clone
in interface ParameterValueGroup
clone
in class Parameters
Parameters.copy(ParameterValueGroup, ParameterValueGroup)
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.