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: 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.
    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 been invoked on the values list.
    Example:
    ParameterValue<?>[] parameter = ...; // Defined elsewhere.
    ParameterValueGroup mercator = Mercator.PARAMETERS.createValue();
    mercator.values().addAll(Arrays.asList(parameters));
    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.

    Since:
    0.4
    See Also:
    Default­Parameter­Descriptor­Group, Default­Parameter­Value, Serialized Form

    Defined in the sis-referencing module

    • Constructor Detail

      • DefaultParameterValueGroup

        public DefaultParameterValueGroup​(ParameterDescriptorGroup descriptor)
        Creates a parameter group from the specified descriptor.

        Usage note: Parameter­Value­Group are usually not instantiated directly. Instead, consider invoking descriptor.create­Value() on a descriptor supplied by a map projection or process provider.

        Parameters:
        descriptor - the descriptor for this group.
      • DefaultParameterValueGroup

        public DefaultParameterValueGroup​(ParameterValueGroup parameters)
        Creates a new instance initialized with all values from the specified parameter group. This is a shallow copy constructor, since the values contained in the given group is not cloned.
        Parameters:
        parameters - The parameters to copy values from.
        Since:
        0.6
        See Also:
        clone()