Package org.geotools.parameter
Class ParameterGroup
- Object
-
- Formattable
-
- AbstractParameter
-
- ParameterGroup
-
- All Implemented Interfaces:
Serializable
,Cloneable
,GeneralParameterValue
,ParameterValueGroup
,Cloneable
- Direct Known Subclasses:
MatrixParameters
public class ParameterGroup extends AbstractParameter implements ParameterValueGroup
A group of related parameter values. The same group can be repeated more than once in an operation or higher levelParameterValueGroup
, if those instances contain different values of one or moreParameterValue
s which suitably distinquish among those groups.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD), Jody Garnett (Refractions Research)
- See Also:
DefaultParameterDescriptorGroup
,Parameter
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ParameterValueGroup
EMPTY
An empty parameter value group.-
Fields inherited from class Formattable
SINGLE_LINE
-
-
Constructor Summary
Constructors Constructor Description ParameterGroup(Map<String,?> properties, GeneralParameterValue... values)
Constructs a parameter group from the specified list of parameters.ParameterGroup(ParameterDescriptorGroup descriptor)
Constructs a parameter group from the specified descriptor.ParameterGroup(ParameterDescriptorGroup descriptor, GeneralParameterValue... values)
Constructs a parameter group from the specified descriptor and list of parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParameterValueGroup
addGroup(String name)
Creates a new group of the specified name.ParameterGroup
clone()
Returns a deep copy of this group of parameter values.boolean
equals(Object object)
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 identifier code.List<GeneralParameterValue>
values()
Returns the values in this group.-
Methods inherited from class AbstractParameter
formatWKT, toString, write
-
Methods inherited from class Formattable
cleanupThreadLocals, toWKT, toWKT, toWKT, toWKT
-
-
-
-
Field Detail
-
EMPTY
public static ParameterValueGroup EMPTY
An empty parameter value group. This group contains no parameter value.
-
-
Constructor Detail
-
ParameterGroup
public ParameterGroup(ParameterDescriptorGroup descriptor)
Constructs a parameter group from the specified descriptor. All parameter values will be initialized to their default value.- Parameters:
descriptor
- The descriptor for this group.
-
ParameterGroup
public ParameterGroup(ParameterDescriptorGroup descriptor, GeneralParameterValue... values)
Constructs a parameter group from the specified descriptor and list of parameters.- Parameters:
descriptor
- The descriptor for this group.values
- The list of parameter values.- Throws:
IllegalStateException
- if the number of parameter occurences doesn't matches the number declared in the descriptor.
-
ParameterGroup
public ParameterGroup(Map<String,?> properties, GeneralParameterValue... values)
Constructs a parameter group from the specified list of parameters.- Parameters:
properties
- The properties for the operation parameter group to construct from the list of parameters.values
- The list of parameter values.- Throws:
IllegalStateException
- if the number of parameter occurences doesn't matches the number declared in the descriptor.
-
-
Method Detail
-
getDescriptor
public ParameterDescriptorGroup getDescriptor()
Returns the abstract definition of this group of parameters.- Specified by:
getDescriptor
in interfaceGeneralParameterValue
- Specified by:
getDescriptor
in interfaceParameterValueGroup
- Overrides:
getDescriptor
in classAbstractParameter
- Returns:
- The abstract definition of this parameter or group of parameters.
-
values
public List<GeneralParameterValue> values()
Returns the values in this group. Changes in this list are reflected on thisParameterValueGroup
. The returned list supports theadd
operation.- Specified by:
values
in interfaceParameterValueGroup
- Returns:
- The values in this group.
-
parameter
public ParameterValue parameter(String name) throws ParameterNotFoundException
Returns the value in this group for the specified identifier code. If no parameter value is found but a parameter descriptor is found (which may occurs if the parameter is optional, i.e.minimumOccurs == 0
), then a parameter value is automatically created and initialized to its default value (if any).This convenience method provides a way to get and set parameter values by name. For example the following idiom fetches a floating point value for the
"false_easting"
parameter:double value = parameter("false_easting").doubleValue();
This method do not search recursively in subgroups. This is because more than one subgroup may exist for the same descriptor. The user must query all subgroups and select explicitly the appropriate one to use.
- Specified by:
parameter
in interfaceParameterValueGroup
- Parameters:
name
- The case insensitive identifier code of the parameter to search for.- Returns:
- The parameter value for the given identifier code.
- Throws:
ParameterNotFoundException
- if there is no parameter value for the given identifier code.
-
groups
public List<ParameterValueGroup> groups(String name) throws ParameterNotFoundException
Returns all subgroups with the specified name. This method do not create new groups. If the requested group is optional (i.e.minimumOccurs == 0
) and no value were set, then this method returns an empty set.- Specified by:
groups
in interfaceParameterValueGroup
- Parameters:
name
- The case insensitive identifier code of the parameter group to search for.- Returns:
- The set of all parameter group for the given identifier code.
- Throws:
ParameterNotFoundException
- if no descriptor was found for the given name.
-
addGroup
public ParameterValueGroup addGroup(String name) throws ParameterNotFoundException, InvalidParameterCardinalityException
Creates a new group of the specified name. The specified name must be the identifier code of a descriptor group.- Specified by:
addGroup
in interfaceParameterValueGroup
- Parameters:
name
- The case insensitive identifier code of the parameter group to create.- Returns:
- A newly created parameter group for the given identifier code.
- Throws:
ParameterNotFoundException
- if no descriptor was found for the given name.InvalidParameterCardinalityException
- if this parameter group already contains the maximum number of occurences of subgroups of the given name.
-
equals
public boolean equals(Object object)
Compares the specified object with this parameter for equality.- Overrides:
equals
in classAbstractParameter
- Parameters:
object
- The object to compare tothis
.- Returns:
true
if both objects are equal.
-
hashCode
public int hashCode()
Returns a hash value for this parameter.- Overrides:
hashCode
in classAbstractParameter
- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
clone
public ParameterGroup clone()
Returns a deep copy of this group of parameter values. Included parameter values and subgroups are cloned recursively.- Specified by:
clone
in interfaceCloneable
- Specified by:
clone
in interfaceGeneralParameterValue
- Specified by:
clone
in interfaceParameterValueGroup
- Overrides:
clone
in classAbstractParameter
- Returns:
- A copy of this group of parameter values.
- See Also:
Object.clone()
-
-