Package org.apache.sis.parameter
Class DefaultParameterDescriptorGroup
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.AbstractIdentifiedObject
org.apache.sis.parameter.AbstractParameterDescriptor
org.apache.sis.parameter.DefaultParameterDescriptorGroup
- All Implemented Interfaces:
Serializable
,Formattable
,Deprecable
,LenientComparable
,org.opengis.parameter.GeneralParameterDescriptor
,org.opengis.parameter.ParameterDescriptorGroup
,org.opengis.referencing.IdentifiedObject
- Direct Known Subclasses:
Affine.Descriptor
,MapProjectionDescriptor
public class DefaultParameterDescriptorGroup
extends AbstractParameterDescriptor
implements org.opengis.parameter.ParameterDescriptorGroup
The definition of a group of related parameters used by an operation method.
DefaultParameterDescriptorGroup
instances are immutable and thus thread-safe.
Instantiation
Parameter descriptors are usually predefined by the SIS library and available through the following methods: If nevertheless aParameterDescriptorGroup
needs to be instantiated directly,
then the ParameterBuilder
class may make the task easier.
Example:
The following example declares the parameters for a Mercator (variant A) projection method
valid from 80°S to 84°N on all the longitude range (±180°).
- Since:
- 0.4
- Version:
- 0.6
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Thedescriptors
as an unmodifiable list. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<org.opengis.parameter.GeneralParameterDescriptor> The parameter descriptors for this group.private static final long
Serial number for inter-operability with different versions.Fields inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
DEPRECATED_KEY, LOCALE_KEY
Fields inherited from interface org.opengis.referencing.IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Constructs a new object in which every attributes are set to a null value or an empty list.DefaultParameterDescriptorGroup
(Map<String, ?> properties, int minimumOccurs, int maximumOccurs, org.opengis.parameter.GeneralParameterDescriptor... parameters) Constructs a parameter group from a set of properties.(package private)
DefaultParameterDescriptorGroup
(Map<String, ?> properties, org.opengis.parameter.GeneralParameterDescriptor[] parameters) Creates a mandatory parameter group without cloning the given array.DefaultParameterDescriptorGroup
(Map<String, ?> properties, org.opengis.parameter.ParameterDescriptorGroup parameters) Constructs a group with the same parameters than another group.protected
DefaultParameterDescriptorGroup
(org.opengis.parameter.ParameterDescriptorGroup descriptor) Creates a new descriptor with the same values than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionprivate static List
<org.opengis.parameter.GeneralParameterDescriptor> asList
(org.opengis.parameter.GeneralParameterDescriptor[] parameters) Returns the given array of parameters as an unmodifiable list.castOrCopy
(org.opengis.parameter.ParameterDescriptorGroup object) Returns a SIS group implementation with the same values than the given arbitrary implementation.protected long
Invoked byAbstractIdentifiedObject.hashCode()
for computing the hash code when first needed.org.opengis.parameter.ParameterValueGroup
Creates a new instance of parameter value group initialized with the default values.org.opengis.parameter.GeneralParameterDescriptor
descriptor
(String name) Returns the first parameter in this group for the specified name.List
<org.opengis.parameter.GeneralParameterDescriptor> Returns all parameters in this group.boolean
equals
(Object object, ComparisonMode mode) Compares the specified object with this parameter group for equality.private org.opengis.parameter.GeneralParameterDescriptor[]
Invoked by JAXB for getting the parameters to marshal.Class
<? extends org.opengis.parameter.ParameterDescriptorGroup> Returns the GeoAPI interface implemented by this class.(package private) final void
merge
(org.opengis.parameter.GeneralParameterDescriptor[] fromValues, Map<org.opengis.parameter.GeneralParameterDescriptor, org.opengis.parameter.GeneralParameterDescriptor> replacements) Merges the given parameter descriptors with the descriptors currently in this group.private void
setDescriptors
(org.opengis.parameter.GeneralParameterDescriptor[] parameters) Invoked by JAXB for setting the unmarshalled parameter descriptors.private static void
verifyNames
(Map<String, ?> properties, org.opengis.parameter.GeneralParameterDescriptor[] parameters) Ensures that the given name array does not contain duplicate values.Methods inherited from class org.apache.sis.parameter.AbstractParameterDescriptor
formatTo, getMaximumOccurs, getMinimumOccurs, print, toString
Methods inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
castOrCopy, equals, formatTo, getAlias, getDescription, getIdentifiers, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForName
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
toString, toWKT
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.parameter.GeneralParameterDescriptor
getMaximumOccurs, getMinimumOccurs
Methods inherited from interface org.opengis.referencing.IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
descriptors
The parameter descriptors for this group.Consider this field as final! This field is modified only at unmarshalling time by
setDescriptors(GeneralParameterDescriptor[])
- See Also:
-
-
Constructor Details
-
DefaultParameterDescriptorGroup
public DefaultParameterDescriptorGroup(Map<String, ?> properties, int minimumOccurs, int maximumOccurs, org.opengis.parameter.GeneralParameterDescriptor... parameters) Constructs a parameter group from a set of properties. The properties map is given unchanged to the super-class constructor. The following table is a reminder of main (not all) properties:Recognized properties (non exhaustive list) Property name Value type Returned by "name" ReferenceIdentifier
orString
AbstractIdentifiedObject.getName()
"alias" GenericName
orCharSequence
(optionally as array)AbstractIdentifiedObject.getAlias()
"identifiers" ReferenceIdentifier
(optionally as array)AbstractIdentifiedObject.getIdentifiers()
"description" InternationalString
orString
AbstractIdentifiedObject.getDescription()
"remarks" InternationalString
orString
AbstractIdentifiedObject.getRemarks()
- Parameters:
properties
- the properties to be given to the new parameter group.minimumOccurs
- the minimum number of times that values for this parameter group are required, or 0 if no restriction.maximumOccurs
- the maximum number of times that values for this parameter group are required, orInteger.MAX_VALUE
if no restriction.parameters
- the parameter descriptors for this group.- Throws:
org.opengis.parameter.InvalidParameterNameException
- if a parameter name is duplicated.
-
DefaultParameterDescriptorGroup
public DefaultParameterDescriptorGroup(Map<String, ?> properties, org.opengis.parameter.ParameterDescriptorGroup parameters) Constructs a group with the same parameters than another group. This is a convenience constructor for operations that expect the same parameters than another operation, but perform a different process.Example: the various "Coordinate Frame Rotation" variants (EPSG codes 1032, 1038 and 9607) expect the same parameters than their "Position Vector transformation" counterpart (EPSG codes 1033, 1037 and 9606) but perform the rotation in the opposite direction.- Parameters:
properties
- the properties to be given to the new parameter group.parameters
- the existing group from which to copy the parameter descriptors.- Since:
- 0.7
-
DefaultParameterDescriptorGroup
DefaultParameterDescriptorGroup(Map<String, ?> properties, org.opengis.parameter.GeneralParameterDescriptor[] parameters) Creates a mandatory parameter group without cloning the given array. This constructor shall be used only when we know that the given array is already a copy of the user-provided array. -
DefaultParameterDescriptorGroup
protected DefaultParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup descriptor) Creates a new descriptor with the same values than the specified one. This copy constructor provides a way to convert an arbitrary implementation into a SIS one or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.This constructor performs a shallow copy, i.e. the properties are not cloned.
- Parameters:
descriptor
- the descriptor to shallow copy.- See Also:
-
DefaultParameterDescriptorGroup
DefaultParameterDescriptorGroup()Constructs a new object in which every attributes are set to a null value or an empty list. This is not a valid object. This constructor is strictly reserved to JAXB and toDefaultParameterValueGroup
, which will assign values later.- See Also:
-
-
Method Details
-
verifyNames
private static void verifyNames(Map<String, ?> properties, org.opengis.parameter.GeneralParameterDescriptor[] parameters) Ensures that the given name array does not contain duplicate values.- Parameters:
properties
- the properties given to the constructor, ornull
if unknown.
-
asList
private static List<org.opengis.parameter.GeneralParameterDescriptor> asList(org.opengis.parameter.GeneralParameterDescriptor[] parameters) Returns the given array of parameters as an unmodifiable list. -
castOrCopy
public static DefaultParameterDescriptorGroup castOrCopy(org.opengis.parameter.ParameterDescriptorGroup object) Returns a SIS group implementation with the same values than the given arbitrary implementation. If the given object isnull
, then this method returnsnull
. Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. Otherwise a new SIS implementation is created and initialized to the values of the given object.- Parameters:
object
- the object to get as a SIS implementation, ornull
if none.- Returns:
- a SIS implementation containing the values of the given object (may be the
given object itself), or
null
if the argument was null.
-
getInterface
Returns the GeoAPI interface implemented by this class. The SIS implementation returnsParameterDescriptorGroup.class
.Note for implementers: Subclasses usually do not need to override this method since GeoAPI does not defineParameterDescriptorGroup
sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their own set of interfaces.- Overrides:
getInterface
in classAbstractParameterDescriptor
- Returns:
ParameterDescriptorGroup.class
or a user-defined sub-interface.
-
descriptors
Returns all parameters in this group.- Specified by:
descriptors
in interfaceorg.opengis.parameter.ParameterDescriptorGroup
- Returns:
- the parameter descriptors in this group.
-
descriptor
public org.opengis.parameter.GeneralParameterDescriptor descriptor(String name) throws org.opengis.parameter.ParameterNotFoundException Returns the first parameter in this group for the specified name. This method does not search in sub-groups.- Specified by:
descriptor
in interfaceorg.opengis.parameter.ParameterDescriptorGroup
- Parameters:
name
- the name of the parameter to search for.- Returns:
- the parameter for the given identifier name.
- Throws:
org.opengis.parameter.ParameterNotFoundException
- if there is no parameter for the given name.
-
createValue
public org.opengis.parameter.ParameterValueGroup createValue()Creates a new instance of parameter value group initialized with the default values. The parameter descriptor for the created group will bethis
object.- Specified by:
createValue
in interfaceorg.opengis.parameter.GeneralParameterDescriptor
- Specified by:
createValue
in interfaceorg.opengis.parameter.ParameterDescriptorGroup
- Returns:
- a new parameter instance initialized to the default value.
-
equals
Compares the specified object with this parameter group for equality.- Specified by:
equals
in interfaceLenientComparable
- Overrides:
equals
in classAbstractParameterDescriptor
- Parameters:
object
- the object to compare tothis
.mode
- the strictness level of the comparison.- Returns:
true
if both objects are equal according the given comparison mode.- See Also:
-
computeHashCode
protected long computeHashCode()Invoked byAbstractIdentifiedObject.hashCode()
for computing the hash code when first needed.- Overrides:
computeHashCode
in classAbstractIdentifiedObject
- Returns:
- the hash code value. This value may change in any future Apache SIS version.
-
getDescriptors
private org.opengis.parameter.GeneralParameterDescriptor[] getDescriptors()Invoked by JAXB for getting the parameters to marshal. -
setDescriptors
private void setDescriptors(org.opengis.parameter.GeneralParameterDescriptor[] parameters) Invoked by JAXB for setting the unmarshalled parameter descriptors. -
merge
final void merge(org.opengis.parameter.GeneralParameterDescriptor[] fromValues, Map<org.opengis.parameter.GeneralParameterDescriptor, org.opengis.parameter.GeneralParameterDescriptor> replacements) Merges the given parameter descriptors with the descriptors currently in this group. The descriptors are set twice duringDefaultParameterValueGroup
unmarshalling:- First, the descriptors are set during unmarshalling of this
DefaultParameterDescriptorGroup
. But the value class ofParameterDescriptor
components are unknown because this information is not part of GML. - Next, this method is invoked during unmarshalling of the
DefaultParameterValueGroup
enclosing element with the descriptors found inside theParameterValue
components. The latter do have thevalueClass
information, so we want to use them in replacement of descriptors of step 1.
- Parameters:
fromValues
- descriptors declared in theParameterValue
instances of aParameterValueGroup
.replacements
- anIdentityHashMap
where to store the replacements that the caller needs to apply in theGeneralParameterValue
instances.
- First, the descriptors are set during unmarshalling of this
-