Class DefaultParameterValueGroup

All Implemented Interfaces:
Serializable, Cloneable, Lenient­Comparable, General­Parameter­Value, Parameter­Value­Group

public class DefaultParameterValueGroup extends Parameters implements LenientComparable, Serializable
A group of related parameter values. Parameter groups have some similarities with java​.util​.Map:

Instantiation and validity constraints

Parameter­Value­Group instances are typically created by calls to descriptor.create­Value() 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 Invalid­Parameter­Cardinality­Exception will be thrown.

Setting the parameter values

After a new Parameter­Value­Group instance has been created, the parameter values can be set by chaining calls to parameter(String) with one of the set­Value(…) 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.

Example 1

Assuming the descriptor defined in the Default­Parameter­Descriptor­Group 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.

Example 2

Alternatively, if all parameters were created elsewhere and the user wants to copy them in a new parameter group, the List​.add­All(Collection) method can be invoked on the values list.
ParameterValue<?>[] parameter = ...;        // Defined elsewhere.
ParameterValueGroup mercator = Mercator.PARAMETERS.createValue();
Collections.addAll(mercator.values(), parameters);

Removing elements

Optional parameters can be removed by the usual List​.remove(int) or List​.remove(Object) operations on the values list. But attempts to remove a mandatory parameter will cause an Invalid­Parameter­Cardinality­Exception to be thrown.

Calls to values()​.clear() restore this Default­Parameter­Value­Group to its initial state.

See Also: