Package org.apache.sis.parameter
Class UnmodifiableParameterValue<T>
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.parameter.DefaultParameterValue<T>
org.apache.sis.parameter.UnmodifiableParameterValue<T>
- Type Parameters:
T
- the type of the value stored in this parameter.
- All Implemented Interfaces:
Serializable
,Cloneable
,LenientComparable
,org.opengis.parameter.GeneralParameterValue
,org.opengis.parameter.ParameterValue<T>
A parameter value which cannot be modified. This implementation shall be used only with:
- immutable descriptor,
- immutable or null unit, and
- immutable or cloneable parameter value.
Cloneable
interface and has a public clone()
method,
then that value will be cloned every time the getValue()
method is invoked.
The value is not cloned by this method however; it is caller's responsibility to not modify the value of
the given parameter
instance after this method call.
Instances sharing
If thecreate(ParameterValue)
method is invoked more than once with equal descriptor, value and unit,
then the method will return the same UnmodifiableParameterValue
instance on a best effort
basis.
Rational:
the same parameter value is often used in many different coordinate operations. For example, all Universal
Transverse Mercator (UTM) projections use the same scale factor (0.9996) and false easting (500000 metres).
- Since:
- 0.6
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final WeakHashSet<UnmodifiableParameterValue>
Pool of parameter instances created in this running JVM.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.parameter.DefaultParameterValue
unit, value
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
UnmodifiableParameterValue
(org.opengis.parameter.ParameterValue<T> value) Creates a new parameter with the same value than the given one. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a modifiable copy of this parameter.(package private) static <T> UnmodifiableParameterValue<T>
create
(org.opengis.parameter.ParameterValue<T> parameter) Returns an unmodifiable implementation of the given parameter value.getValue()
If the value is cloneable, clones it before to return it.protected void
Do not allow modification of the parameter value.Methods inherited from class org.apache.sis.parameter.DefaultParameterValue
booleanValue, doubleValue, doubleValue, doubleValueList, doubleValueList, equals, equals, formatTo, getDescriptor, getUnit, hashCode, intValue, intValueList, setDescriptor, setValue, setValue, setValue, setValue, setValue, setValue, stringValue, unmodifiable, validate, valueFile
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toString, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
POOL
Pool of parameter instances created in this running JVM. See class javadoc for a rational about why we use a pool.
-
-
Constructor Details
-
UnmodifiableParameterValue
Creates a new parameter with the same value than the given one.
-
-
Method Details
-
create
Returns an unmodifiable implementation of the given parameter value. See class javadoc for more information.- Type Parameters:
T
- the type of the value stored in the given parameter.- Parameters:
parameter
- the parameter to make unmodifiable, ornull
.- Returns:
- an unmodifiable implementation of the given parameter, or
null
if the given parameter was null.
-
getValue
If the value is cloneable, clones it before to return it.- Specified by:
getValue
in interfaceorg.opengis.parameter.ParameterValue<T>
- Overrides:
getValue
in classDefaultParameterValue<T>
- Returns:
- the parameter value as an object, or
null
if no value has been set and there is no default value. - See Also:
-
setValue
Do not allow modification of the parameter value.- Overrides:
setValue
in classDefaultParameterValue<T>
- Parameters:
value
- the parameter value, ornull
to restore the default.unit
- the unit associated to the new parameter value, ornull
.- See Also:
-
clone
Returns a modifiable copy of this parameter.- Specified by:
clone
in interfaceorg.opengis.parameter.GeneralParameterValue
- Specified by:
clone
in interfaceorg.opengis.parameter.ParameterValue<T>
- Overrides:
clone
in classDefaultParameterValue<T>
- See Also:
-