public class ParameterBuilder extends Builder<ParameterBuilder>
ParameterDescriptor.createValue()
on the descriptor provided by the implementor.
addName(…)
methods.
Parameters can optionally have an arbitrary amount of aliases, which are also specified by the
addName(…)
methods — each call after the first one adds an alias.
Parameters can also have an arbitrary amount of identifiers, which are specified by the
addIdentifier(…)
methods. Like names, more than one identifier can be added by invoking
the method many time.
Parameters can have at most one remark, which is specified by the setRemarks(…)
method.
All the above-cited properties are cleared after a call to any createXXX(…)
method,
since those properties are specific to the each parameter. Other properties like codespace,
version and cardinality are left unchanged because they may be shared by many parameters.
ParameterDescriptorGroup
.
All parameters usually have the same namespace, which can be declared only once.
The following example creates parameters for "Mercator (variant A)" projection method (EPSG:9804)
with all parameter names in the "EPSG" namespace. The default values define a projection centered on (0°,0°),
with no scale factor and no false easting/northing. The projection is valid from 80°S to 84°N and on all the
longitude range (±180°).
Parameters often have more than one name, because different softwares or standards use different conventions. In the above example, the line creating the Longitude of natural origin parameter could be replaced by the following code in order to declare its aliases:ParameterBuilder builder = new ParameterBuilder(); builder.setCodeSpace(Citations.OGP, "EPSG").setRequired(true); ParameterDescriptor<?>[] parameters = { builder.addName("Latitude of natural origin") .createBounded( -80, +84, 0, NonSI.DEGREE_ANGLE), builder.addName("Longitude of natural origin") .createBounded(-180, +180, 0, NonSI.DEGREE_ANGLE), builder.addName("Scale factor at natural origin").createStrictlyPositive(1, Unit.ONE), builder.addName("False easting") .create(0, SI.METRE), builder.addName("False northing") .create(0, SI.METRE) };
builder.addIdentifier("8802") // Primary key in builder default namespace (EPSG in this example). .addName("Longitude of natural origin") // Primary name in builder default namespace (EPSG in this example). .addName(Citations.OGC, "central_meridian") // First alias in "OGC" namespace. .addName(Citations.GEOTIFF, "NatOriginLong") // Second alias in "GeoTIFF" namespace. .createBounded(-80, +84, 0, NonSI.DEGREE_ANGLE);
Defined in the sis-referencing
module
properties
Constructor and Description |
---|
ParameterBuilder()
Creates a new builder.
|
Modifier and Type | Method and Description |
---|---|
<T> ParameterDescriptor<T> |
create(Class<T> valueClass,
T defaultValue)
Creates a descriptor for values of the given type without domain restriction.
|
ParameterDescriptor<Double> |
create(double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values without domain restriction.
|
<T extends Comparable<? super T>> |
createBounded(Class<T> valueClass,
T minimumValue,
T maximumValue,
T defaultValue)
Creates a descriptor for values of the given type restricted to the given domain.
|
ParameterDescriptor<Double> |
createBounded(double minimumValue,
double maximumValue,
double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values restricted to the given domain.
|
ParameterDescriptor<Integer> |
createBounded(int minimumValue,
int maximumValue,
int defaultValue)
Creates a descriptor for integer values restricted to the given domain.
|
<T extends Comparable<? super T>> |
createBounded(Range<T> valueDomain,
T defaultValue)
Creates a descriptor for values in the domain represented by the given
Range object. |
<T> ParameterDescriptor<T> |
createEnumerated(Class<T> valueClass,
T[] validValues,
T defaultValue)
Creates a descriptor for a parameter restricted to a set of valid values.
|
ParameterDescriptorGroup |
createGroup(GeneralParameterDescriptor... parameters)
Creates a descriptor group for the given parameters.
|
ParameterDescriptorGroup |
createGroup(int minimumOccurs,
int maximumOccurs,
GeneralParameterDescriptor... parameters)
Creates a descriptor group for the given cardinality and parameters.
|
ParameterDescriptor<Double> |
createStrictlyPositive(double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values greater than zero.
|
ParameterBuilder |
setRequired(boolean required)
Sets whether the parameter is mandatory or optional.
|
addIdentifier, addIdentifier, addIdentifier, addName, addName, addName, addName, onCreate, setCodeSpace, setDescription, setRemarks, setVersion
public ParameterBuilder setRequired(boolean required)
Default value:
If this method is never invoked, then the default value is false
.
Lifetime:
this property is kept unchanged until this setRequired(…)
method is invoked again.
required
- true
for a mandatory parameter, or false
for an optional one.this
, for method call chaining.public ParameterDescriptor<Double> create(double defaultValue, Unit<?> unit)
double
values are considered valid.defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The default unit, or null
if none.public <T> ParameterDescriptor<T> create(Class<T> valueClass, T defaultValue)
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.defaultValue
- The default value for the parameter, or null
if none.public ParameterDescriptor<Double> createStrictlyPositive(double defaultValue, Unit<?> unit)
defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The default unit, or null
if none.public ParameterDescriptor<Double> createBounded(double minimumValue, double maximumValue, double defaultValue, Unit<?> unit)
minimumValue
- The minimum parameter value (inclusive), or Double.NEGATIVE_INFINITY
if none.maximumValue
- The maximum parameter value (inclusive), or Double.POSITIVE_INFINITY
if none.defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The unit for default, minimum and maximum values, or null
if none.public ParameterDescriptor<Integer> createBounded(int minimumValue, int maximumValue, int defaultValue)
minimumValue
- The minimum parameter value (inclusive).maximumValue
- The maximum parameter value (inclusive).defaultValue
- The default value for the parameter.public <T extends Comparable<? super T>> ParameterDescriptor<T> createBounded(Class<T> valueClass, T minimumValue, T maximumValue, T defaultValue)
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.minimumValue
- The minimum parameter value (inclusive), or null
if none.maximumValue
- The maximum parameter value (inclusive), or null
if none.defaultValue
- The default value for the parameter, or null
if none.public <T extends Comparable<? super T>> ParameterDescriptor<T> createBounded(Range<T> valueDomain, T defaultValue)
Range
object.
This method allows to specify whether the minimum and maximum values are inclusive or not.T
- The type of the parameter values.valueDomain
- The minimum value, maximum value and unit of measurement.defaultValue
- The default value for the parameter, or null
if none.public <T> ParameterDescriptor<T> createEnumerated(Class<T> valueClass, T[] validValues, T defaultValue)
The validValues
property is mostly for restricting values to
a code list or enumeration subset.
It is not necessary to provide this property when all values from the code list or enumeration are valid.
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.validValues
- A finite set of valid values (usually from a code list or enumeration)
or null
if it doesn't apply.defaultValue
- The default value for the parameter, or null
if none.public ParameterDescriptorGroup createGroup(GeneralParameterDescriptor... parameters)
createGroup(int, int, GeneralParameterDescriptor[])
with a cardinality of [0 … 1]
or [1 … 1] depending on the value given to the last call to setRequired(boolean)
.parameters
- The parameter descriptors
for the group to create.public ParameterDescriptorGroup createGroup(int minimumOccurs, int maximumOccurs, GeneralParameterDescriptor... parameters)
minimumOccurs
- The minimum
number of times that values for this parameter group are required.maximumOccurs
- The maximum
number of times that values for this parameter group are required.parameters
- The parameter descriptors
for the group to create.Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.