Package org.opengis.example.parameter
Class SimpleParameterGroup
- Object
-
- SimpleIdentifiedObject
-
- SimpleParameterGroup
-
- All Implemented Interfaces:
Serializable,Cloneable,Identifier,GeneralParameterDescriptor,GeneralParameterValue,ParameterDescriptorGroup,ParameterValueGroup,IdentifiedObject,ReferenceIdentifier
public class SimpleParameterGroup extends SimpleIdentifiedObject implements ParameterValueGroup, ParameterDescriptorGroup, Cloneable
AParameterValueGroupimplementation forSimpleParameterinstances. In order to keep the conceptual model simpler, this parameter group is also its own descriptor. This is not quite a recommended practice (such descriptors are less suitable for use inHashMap), but allow us to keep the amount of classes smaller and closely related interfaces together.The most interesting methods in this class are:
SimpleIdentifiedObject.getName(), for the name of this parameter groupparameter(String), for getting a parameter of the given name.
- Since:
- 3.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<SimpleParameter>parametersThe list of parameters included in this group.-
Fields inherited from class SimpleIdentifiedObject
authority, code
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Fields inherited from interface Identifier
AUTHORITY_KEY, CODE_KEY, CODESPACE_KEY, DESCRIPTION_KEY, VERSION_KEY
-
-
Constructor Summary
Constructors Constructor Description SimpleParameterGroup(Citation authority, String name, SimpleParameter... param)Creates a new parameter group of the given authority and name.
-
Method Summary
Modifier and Type Method Description ParameterValueGroupaddGroup(String name)Creates a new group of the specified name.SimpleParameterGroupclone()Returns a copy of this parameter group.SimpleParameterGroupcreateValue()GeneralParameterDescriptordescriptor(String name)Returns the parameter descriptor in this group for the specified identifier code.List<GeneralParameterDescriptor>descriptors()Returns the parameter descriptors in this group.booleanequals(Object object)Compares the given object with this parameter group for equality.InternationalStringgetDescription()Returns a natural language description of this object.ParameterDescriptorGroupgetDescriptor()Returns the descriptor of the parameter group.ParameterDirectiongetDirection()Returnsthis, since this simple class is used only as input parameters.List<ParameterValueGroup>groups(String name)Returns all subgroups with the specified name.inthashCode()Returns a hash code value for this parameter.ParameterValue<?>parameter(String name)Returns the value in this group for the specified identifier code.StringtoString()Returns a string representation of all parameters in this group.List<GeneralParameterValue>values()Returns the parameter values in this group.-
Methods inherited from class SimpleIdentifiedObject
getAuthority, getCode, getCodeSpace, getDomainOfValidity, getName, getScope, toWKT
-
Methods inherited from interface GeneralParameterDescriptor
getMaximumOccurs, getMinimumOccurs, getName
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getRemarks, toWKT
-
Methods inherited from interface Identifier
getVersion
-
-
-
-
Field Detail
-
parameters
protected final List<SimpleParameter> parameters
The list of parameters included in this group. This simple group implementation supports onlySimpleParameterinstances, which are used both as parameter descriptor and parameter values for thedoublevalue type.This list is live: changes to this list will be reflected immediately in the
descriptors()andvalues()views.
-
-
Constructor Detail
-
SimpleParameterGroup
public SimpleParameterGroup(Citation authority, String name, SimpleParameter... param)
Creates a new parameter group of the given authority and name.- Parameters:
authority- organization responsible for definition of the parameters, ornull.name- the parameter group name.param- the parameters to be included in this group.
-
-
Method Detail
-
getDescriptor
public ParameterDescriptorGroup getDescriptor()
Returns the descriptor of the parameter group. Since this simple class implements both the value and descriptor interfaces, this method returnsthis. However more sophisticated libraries are likely to return a different object.- Specified by:
getDescriptorin interfaceGeneralParameterValue- Specified by:
getDescriptorin interfaceParameterValueGroup- Returns:
thisdescriptor.
-
getDescription
public InternationalString getDescription()
Returns a natural language description of this object. The default implementation returnsnull.- Specified by:
getDescriptionin interfaceGeneralParameterDescriptor- Specified by:
getDescriptionin interfaceIdentifier- Returns:
- the natural language description, or
nullif none.
-
getDirection
public ParameterDirection getDirection()
Returnsthis, since this simple class is used only as input parameters.- Specified by:
getDirectionin interfaceGeneralParameterDescriptor
-
descriptors
public List<GeneralParameterDescriptor> descriptors()
Returns the parameter descriptors in this group. The list returned by this method is unmodifiable.Implementation note: Since the simple classes in this package implement both the value and the descriptor interfaces, this method returns the same list than thevalues()methods. However more sophisticated libraries are likely to return a distinct list.- Specified by:
descriptorsin interfaceParameterDescriptorGroup- Returns:
- the parameter descriptors in this group as an unmodifiable list.
-
values
public List<GeneralParameterValue> values()
Returns the parameter values in this group. The list returned by this method is unmodifiable.Implementation note: Since the simple classes in this package implement both the value and the descriptor interfaces, this method returns the same list than thedescriptors()methods. However more sophisticated libraries are likely to return a distinct list.- Specified by:
valuesin interfaceParameterValueGroup- Returns:
- the parameter values in this group as an unmodifiable list.
-
descriptor
public GeneralParameterDescriptor descriptor(String name) throws ParameterNotFoundException
Returns the parameter descriptor in this group for the specified identifier code.Implementation note: Since the simple classes in this package implement both the value and the descriptor interfaces, this method is essentially synonymous toparameter(String). However more sophisticated libraries are likely to return a distinct object.- Specified by:
descriptorin interfaceParameterDescriptorGroup- Parameters:
name- the case insensitive identifier code of the parameter to search for.- Returns:
- the parameter for the given identifier code.
- Throws:
ParameterNotFoundException- if there is no parameter for the given identifier code.
-
parameter
public ParameterValue<?> parameter(String name) throws ParameterNotFoundException
Returns the value in this group for the specified identifier code. 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:
The following idiom sets a floating point value for thedouble value = parameter("false_easting").doubleValue();"false_easting"parameter:parameter("false_easting").setValue(500000.0);Implementation note: Since the simple classes in this package implement both the value and the descriptor interfaces, this method is essentially synonymous todescriptor(String). However more sophisticated libraries are likely to return a distinct object.- Specified by:
parameterin 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. The default implementation always throws an exception, since this simple parameter group does not support subgroups.- Specified by:
groupsin 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
Creates a new group of the specified name. The default implementation always throws an exception, since this simple parameter group does not support subgroups.- Specified by:
addGroupin 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.
-
createValue
public SimpleParameterGroup createValue()
Returns a new group with the same authority, code and parameters than this group. The value of each parameter is left to their default value.Implementation note: Since this simple class implements both the value and the descriptor interfaces, this method is very similar to theclone()method. However in more sophisticated libraries, theParameterDescriptorGroup.createValue()andParameterValueGroup.clone()methods are likely to be defined in different objects.- Specified by:
createValuein interfaceGeneralParameterDescriptor- Specified by:
createValuein interfaceParameterDescriptorGroup- See Also:
clone()
-
clone
public SimpleParameterGroup clone()
Returns a copy of this parameter group. This method is similar tocreateValue()except for the following:- This method returns an instance of the same class.
- The values() are initialized to the same values than the cloned group.
- Specified by:
clonein interfaceGeneralParameterValue- Specified by:
clonein interfaceParameterValueGroup- Overrides:
clonein classObject- See Also:
createValue()
-
equals
public boolean equals(Object object)
Compares the given object with this parameter group for equality.- Overrides:
equalsin classSimpleIdentifiedObject- Parameters:
object- the object to compare with thisSimpleIdentifiedObject.- Returns:
trueif the given object is equals to this object.
-
hashCode
public int hashCode()
Returns a hash code value for this parameter.- Overrides:
hashCodein classSimpleIdentifiedObject
-
toString
public String toString()
Returns a string representation of all parameters in this group.- Overrides:
toStringin classSimpleIdentifiedObject
-
-