Package org.apache.sis.parameter
Class DefaultParameterValueGroup
Object
Parameters
DefaultParameterValueGroup
- All Implemented Interfaces:
- Serializable,- Cloneable,- LenientComparable,- GeneralParameterValue,- ParameterValueGroup
public class DefaultParameterValueGroup
extends Parameters
implements LenientComparable, Serializable
A group of related parameter values. Parameter groups have some similarities with 
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- ParameterValueplaying a role similar to- Map.Entry.
Instantiation and validity constraints
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.
 Setting the parameter values
After a newParameterValueGroup 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.
 Example:
 Assuming the descriptor defined in the 
 Alternatively, if all parameters were created elsewhere and the user wants to copy them in a new
 parameter group, the 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 be invoked on the values list.
 Example:
 
 Optional parameters can be removed by the usual ParameterValue<?>[] parameter = ...; // Defined elsewhere. ParameterValueGroup mercator = Mercator.PARAMETERS.createValue(); Collections.addAll(mercator.values(), 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.
- Since:
- 0.4
- See Also:
Defined in the sis-referencing module
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a parameter group from the specified descriptor.DefaultParameterValueGroup(ParameterValueGroup parameters) Creates a new instance initialized with all values from the specified parameter group.
- 
Method SummaryModifier and TypeMethodDescriptionCreates a new subgroup of the specified name, and adds it to the list of subgroups.clone()Returns a deep copy of this group of parameter values.final booleanCompares the specified object with this parameter for equality.booleanequals(Object object, ComparisonMode mode) Compares the specified object with this parameter for equality.Returns the abstract definition of this group of parameters.<T> ParameterValue<T>getOrCreate(ParameterDescriptor<T> parameter) Returns the parameter identified by the given descriptor.Returns all subgroups with the specified name.intReturns a hash value for this parameter.Returns the value in this group for the specified name.values()Returns the values in this group.Methods inherited from class ParametersbooleanValue, cast, cast, castOrWrap, copy, doubleValue, doubleValue, doubleValueList, getDescriptors, getMandatoryValue, getMemberName, getValue, getValueDomain, intValue, intValueList, isUnmodifiable, print, stringValue, toString, unmodifiable, unmodifiable
- 
Constructor Details- 
DefaultParameterValueGroupCreates a parameter group from the specified descriptor.Usage noteParameterValueGroupare usually not instantiated directly. Instead, consider invokingdescriptor.createValue()on a descriptor supplied by a map projection or process provider.- Parameters:
- descriptor- the descriptor for this group.
 
- 
DefaultParameterValueGroupCreates 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:
 
 
- 
- 
Method Details- 
getDescriptorReturns the abstract definition of this group of parameters.- Specified by:
- getDescriptorin interface- GeneralParameterValue
- Specified by:
- getDescriptorin interface- ParameterValueGroup
- Returns:
- the abstract definition of this group of parameters.
 
- 
valuesReturns the values in this group. The returned list is live: changes in this list are reflected on thisParameterValueGroup, and conversely.RestrictionsAll write operations must comply to the following conditions:- Parameters added to the list shall have one of the descriptors listed by getDescriptor().
- Adding or removing parameters shall not violate the parameter cardinality constraints.
 InvalidParameterNameException,InvalidParameterCardinalityExceptionor other runtime exceptions if a condition is not met.- Specified by:
- valuesin interface- ParameterValueGroup
- Returns:
- the values in this group.
 
- Parameters added to the list shall have one of the descriptors listed by 
- 
getOrCreatepublic <T> ParameterValue<T> getOrCreate(ParameterDescriptor<T> parameter) throws ParameterNotFoundException Returns the parameter identified by the given descriptor. If the identified parameter is optional and not yet created, then it will be created now.- Overrides:
- getOrCreatein class- Parameters
- Type Parameters:
- T- the type of the parameter value.
- Parameters:
- parameter- the parameter to look for.
- Returns:
- the requested parameter instance.
- Throws:
- ParameterNotFoundException- if the given- parametername or alias is not legal for this group.
- See Also:
 
- 
parameterReturns the value in this group for the specified name. This method performs the first applicable action in the following choices:- If this group contains a parameter value of the given name, then that parameter is returned.
- Otherwise if a descriptor of the
       given name exists, then a new ParameterValueinstance is created, added to this group and returned.
- Otherwise a ParameterNotFoundExceptionis thrown.
 double easting = parameter("False easting" ).doubleValue(); double northing = parameter("False northing").doubleValue(); parameter("False easting").setValue(500000.0);API note: there is noparameters(String)method returning a list of parameter values because the ISO 19111 standard fixes theParameterValuemaximum occurrence to 1.Parameters subgroupsThis method does not search recursively in subgroups. This is because more than one subgroup may exist for the same descriptor. The user have to query all subgroups and select explicitly the appropriate one.- Specified by:
- parameterin interface- ParameterValueGroup
- Parameters:
- name- the name of the parameter to search for.
- Returns:
- the parameter value for the given name.
- Throws:
- ParameterNotFoundException- if there is no parameter value for the given name.
- See Also:
 
- 
groupsReturns all subgroups with the specified name. Groups are listed in the order they were added by calls toaddGroup(String).This method does 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.- Specified by:
- groupsin interface- ParameterValueGroup
- Parameters:
- name- the name of the parameter to search for.
- Returns:
- the list of all parameter group for the given name, in insertion order.
- Throws:
- ParameterNotFoundException- if no descriptor was found for the given name.
 
- 
addGrouppublic ParameterValueGroup addGroup(String name) throws ParameterNotFoundException, InvalidParameterCardinalityException Creates a new subgroup of the specified name, and adds it to the list of subgroups. The argument shall be the name of a descriptor group which is a child of this group.API note: There is noremoveGroup(String)method. To remove a group, users can inspect thegroups(String)orvalues()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.- Specified by:
- addGroupin interface- ParameterValueGroup
- Parameters:
- name- the name of the parameter group to create.
- Returns:
- a newly created parameter group for the given name.
- Throws:
- 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.
 
- 
equalsCompares the specified object with this parameter for equality. The strictness level is controlled by the second argument:- ComparisonMode.STRICTand- BY_CONTRACTtake in account the parameter order.
- ComparisonMode.IGNORE_METADATAand- APPROXIMATEignore the order of parameter values (but not necessarily the order of parameter descriptors).
 - Specified by:
- equalsin interface- LenientComparable
- Parameters:
- object- the object to compare to- this.
- mode- the strictness level of the comparison.
- Returns:
- trueif both objects are equal according the given comparison mode.
- See Also:
 
- 
equalsCompares the specified object with this parameter for equality. This method is implemented as below:
 Subclasses shall overridereturn equals(other, ComparisonMode.STRICT); equals(Object, ComparisonMode)instead of this method.- Specified by:
- equalsin interface- LenientComparable
- Overrides:
- equalsin class- Object
- Parameters:
- object- the object to compare to- this.
- Returns:
- trueif both objects are equal.
- See Also:
 
- 
hashCodepublic int hashCode()Returns a hash value for this parameter.
- 
cloneReturns a deep copy of this group of parameter values. Included parameter values and subgroups are cloned recursively.- Specified by:
- clonein interface- GeneralParameterValue
- Specified by:
- clonein interface- ParameterValueGroup
- Overrides:
- clonein class- Parameters
- Returns:
- a copy of this group of parameter values.
- See Also:
 
 
-