Package org.apache.sis.measure
Class SystemUnit.DimToUnit
java.lang.Object
org.apache.sis.internal.converter.SurjectiveConverter<UnitDimension,SystemUnit<?>>
org.apache.sis.measure.SystemUnit.DimToUnit
- All Implemented Interfaces:
Serializable
,Function<UnitDimension,
,SystemUnit<?>> ObjectConverter<UnitDimension,
SystemUnit<?>>
- Enclosing class:
SystemUnit<Q extends javax.measure.Quantity<Q>>
private static final class SystemUnit.DimToUnit
extends SurjectiveConverter<UnitDimension,SystemUnit<?>>
implements Serializable
The converter for replacing the keys in the
SystemUnit.getBaseUnits()
map from UnitDimension
instances to SystemUnit
instances. We apply conversions on the fly instead of extracting the data in
a new map once for all because the copy may fail if an entry contains a rational instead of an integer power.
With on-the-fly conversions, the operation will not fail if the user never ask for that particular value.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final SystemUnit.DimToUnit
The unique instance used bySystemUnit.getBaseUnits()
.private static final long
For cross-version compatibility. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSystemUnit
<?> apply
(UnitDimension dim) Returns the unit associated to the given dimension, ornull
if none.Returns the type of key values in the map returned byUnitDimension.getBaseDimensions()
.Class
<SystemUnit<?>> Returns the type of key values in the map to be returned bySystemUnit.getBaseUnits()
.(package private) Object
Invoked on deserialization for replacing the deserialized instance by the unique instance.Methods inherited from class org.apache.sis.internal.converter.SurjectiveConverter
inverse, properties, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
INSTANCE
The unique instance used bySystemUnit.getBaseUnits()
.
-
-
Constructor Details
-
DimToUnit
private DimToUnit()Constructor for the singletonINSTANCE
.
-
-
Method Details
-
getSourceClass
Returns the type of key values in the map returned byUnitDimension.getBaseDimensions()
.- Specified by:
getSourceClass
in interfaceObjectConverter<UnitDimension,
SystemUnit<?>> - Returns:
- the type of objects to convert.
-
getTargetClass
Returns the type of key values in the map to be returned bySystemUnit.getBaseUnits()
.- Specified by:
getTargetClass
in interfaceObjectConverter<UnitDimension,
SystemUnit<?>> - Returns:
- the type of converted objects.
-
apply
Returns the unit associated to the given dimension, ornull
if none.- Specified by:
apply
in interfaceFunction<UnitDimension,
SystemUnit<?>> - Specified by:
apply
in interfaceObjectConverter<UnitDimension,
SystemUnit<?>> - Parameters:
dim
- the object to convert, ornull
.- Returns:
- the converted object, or
null
.
-
readResolve
Invoked on deserialization for replacing the deserialized instance by the unique instance.- Throws:
ObjectStreamException
-