Package org.apache.sis.parameter

# Class DefaultParameterDescriptorGroup

Object
FormattableObject
AbstractIdentifiedObject
AbstractParameterDescriptor
DefaultParameterDescriptorGroup

All Implemented Interfaces:
  `Serializable`, `Formattable`, `Deprecable`, `LenientComparable`, `GeneralParameterDescriptor`, `ParameterDescriptorGroup`, `IdentifiedObject`

public class DefaultParameterDescriptorGroup extends AbstractParameterDescriptor implements 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 pre-defined by the SIS library and available through the following methods:

- `DefaultOperationMethod​.getParameters()`

If nevertheless a `ParameterDescriptorGroup` 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°).

>     class Mercator {
>         static final ParameterDescriptorGroup PARAMETERS;
>         static {
>             ParameterBuilder builder = new ParameterBuilder();
>             builder.setCodeSpace(Citations.EPSG, "EPSG").setRequired(true);
>             ParameterDescriptor<?>[] parameters = {
>                 builder.addName("Latitude of natural origin")    .createBounded( -80,  +84, 0, Units.DEGREE),
>                 builder.addName("Longitude of natural origin")   .createBounded(-180, +180, 0, Units.DEGREE),
>                 builder.addName("Scale factor at natural origin").createStrictlyPositive(1, Units.UNITY),
>                 builder.addName("False easting")                 .create(0, Units.METRE),
>                 builder.addName("False northing")                .create(0, Units.METRE)
>             };
>             builder.addIdentifier("9804")                    // Primary key in EPSG database.
>                    .addName("Mercator (variant A)")          // EPSG name since October 2010.
>                    .addName("Mercator (1SP)")                // EPSG name prior October 2010.
>                    .addName(Citations.OGC, "Mercator_1SP");  // Name found in some OGC specifications.
>             PARAMETERS = builder.createGroup(parameters);
>         }
>     }

Since:
  0.4
See Also:
  - `DefaultParameterValueGroup`
  - `DefaultParameterDescriptor`
  - Serialized Form

Defined in the `sis-referencing` module

- ## Field Summary

  ### Fields inherited from class AbstractIdentifiedObject

  `DEPRECATED_KEY, LOCALE_KEY`

  ### Fields inherited from interface IdentifiedObject

  `ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `DefaultParameterDescriptorGroup(Map<String,?> properties, int minimumOccurs, int maximumOccurs, GeneralParameterDescriptor... parameters)`
  Constructs a parameter group from a set of properties.
  ``
  `DefaultParameterDescriptorGroup(Map<String,?> properties, ParameterDescriptorGroup parameters)`
  Constructs a group with the same parameters than another group.
  `protected`
  `DefaultParameterDescriptorGroup(ParameterDescriptorGroup descriptor)`
  Creates a new descriptor with the same values than the specified one.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DefaultParameterDescriptorGroup`
  `castOrCopy(ParameterDescriptorGroup object)`
  Returns a SIS group implementation with the same values than the given arbitrary implementation.
  `protected long`
  `computeHashCode()`
  Invoked by `AbstractIdentifiedObject​.hashCode()` for computing the hash code when first needed.
  `ParameterValueGroup`
  `createValue()`
  Creates a new instance of parameter value group initialized with the default values.
  `GeneralParameterDescriptor`
  `descriptor(String name)`
  Returns the first parameter in this group for the specified name.
  `List<GeneralParameterDescriptor>`
  `descriptors()`
  Returns all parameters in this group.
  `boolean`
  `equals(Object object, ComparisonMode mode)`
  Compares the specified object with this parameter group for equality.
  `Class<? extends ParameterDescriptorGroup>`
  `getInterface()`
  Returns the GeoAPI interface implemented by this class.

  ### Methods inherited from class AbstractParameterDescriptor

  `formatTo, getMaximumOccurs, getMinimumOccurs, print, toString`

  ### Methods inherited from class AbstractIdentifiedObject

  `castOrCopy, equals, formatTo, getAlias, getDescription, getIdentifiers, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForName`

  ### Methods inherited from class FormattableObject

  `toString, toWKT`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface GeneralParameterDescriptor

  `getMaximumOccurs, getMinimumOccurs`

  ### Methods inherited from interface IdentifiedObject

  `getAlias, getIdentifiers, getName, getRemarks, toWKT`

- ## Constructor Details

  - ### DefaultParameterDescriptorGroup

    public DefaultParameterDescriptorGroup(Map<String,?> properties, int minimumOccurs, int maximumOccurs, 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` or `String` | `AbstractIdentifiedObject.getName()`
    "alias" | `GenericName` or `CharSequence` (optionally as array) | `AbstractIdentifiedObject.getAlias()`
    "identifiers" | `ReferenceIdentifier` (optionally as array) | `AbstractIdentifiedObject.getIdentifiers()`
    "description" | `InternationalString` or `String` | `AbstractIdentifiedObject.getDescription()`
    "remarks" | `InternationalString` or `String` | `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, or `Integer​.MAX_VALUE` if no restriction.
      `parameters` - the parameter descriptors for this group.
    Throws:
      `InvalidParameterNameException` - if a parameter name is duplicated.

  - ### DefaultParameterDescriptorGroup

    public DefaultParameterDescriptorGroup(Map<String,?> properties, 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

    protected DefaultParameterDescriptorGroup(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:
      - `castOrCopy(ParameterDescriptorGroup)`

- ## Method Details

  - ### castOrCopy

    public static DefaultParameterDescriptorGroup castOrCopy(ParameterDescriptorGroup object)
    Returns a SIS group implementation with the same values than the given arbitrary implementation. If the given object is `null`, then this method returns `null`. 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, or `null` 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

    public Class<? extends ParameterDescriptorGroup> getInterface()
    Returns the GeoAPI interface implemented by this class. The SIS implementation returns `ParameterDescriptorGroup​.class`.
    Note for implementers: Subclasses usually do not need to override this method since GeoAPI does not define `ParameterDescriptorGroup` sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their own set of interfaces.
    Overrides:
      `getInterface` in class `AbstractParameterDescriptor`
    Returns:
      `ParameterDescriptorGroup​.class` or a user-defined sub-interface.

  - ### descriptors

    public List<GeneralParameterDescriptor> descriptors()
    Returns all parameters in this group.
    Specified by:
      `descriptors` in interface `ParameterDescriptorGroup`
    Returns:
      the parameter descriptors in this group.

  - ### descriptor

    public GeneralParameterDescriptor descriptor(String name) throws ParameterNotFoundException
    Returns the first parameter in this group for the specified name. This method does not search in sub-groups.
    Specified by:
      `descriptor` in interface `ParameterDescriptorGroup`
    Parameters:
      `name` - the name of the parameter to search for.
    Returns:
      the parameter for the given identifier name.
    Throws:
      `ParameterNotFoundException` - if there is no parameter for the given name.

  - ### createValue

    public ParameterValueGroup createValue()
    Creates a new instance of parameter value group initialized with the default values. The parameter descriptor for the created group will be `this` object.
    Specified by:
      `createValue` in interface `GeneralParameterDescriptor`
    Specified by:
      `createValue` in interface `ParameterDescriptorGroup`
    Returns:
      a new parameter instance initialized to the default value.

  - ### equals

    public boolean equals(Object object, ComparisonMode mode)
    Compares the specified object with this parameter group for equality.
    Specified by:
      `equals` in interface `LenientComparable`
    Overrides:
      `equals` in class `AbstractParameterDescriptor`
    Parameters:
      `object` - the object to compare to `this`.
      `mode` - the strictness level of the comparison.
    Returns:
      `true` if both objects are equal according the given comparison mode.
    See Also:
      - `AbstractIdentifiedObject​.computeHashCode()`
      - `Utilities​.deepEquals(Object, Object, ComparisonMode)`

  - ### computeHashCode

    protected long computeHashCode()
    Invoked by `AbstractIdentifiedObject​.hashCode()` for computing the hash code when first needed.
    Overrides:
      `computeHashCode` in class `AbstractIdentifiedObject`
    Returns:
      the hash code value. This value may change in any future Apache SIS version.