Package javax.measure.unit
Interface Dimension.Model
-
- All Known Implementing Classes:
HighEnergyModel
,NaturalModel
,PhysicalModel
,QuantumModel
,RelativisticModel
,StandardModel
- Enclosing class:
- Dimension
public static interface Dimension.Model
This interface represents the mapping betweenbase units
anddimensions
. Custom models may allow conversions not possible using thestandard
model. For example:[code] public static void main(String[] args) { Dimension.Model relativistic = new Dimension.Model() { RationalConverter meterToSecond = new RationalConverter(1, 299792458); // 1/c public Dimension getDimension(BaseUnit unit) { if (unit.equals(SI.METER)) return Dimension.TIME; return Dimension.Model.STANDARD.getDimension(unit); } public UnitConverter getTransform(BaseUnit unit) { if (unit.equals(SI.METER)) return meterToSecond; return Dimension.Model.STANDARD.getTransform(unit); }}; Dimension.setModel(relativistic); // Converts 1.0 GeV (energy) to kg (mass). System.out.println(Unit.valueOf("GeV").getConverterTo(KILOGRAM).convert(1.0)); } > 1.7826617302520883E-27[/code]
-
-
Field Summary
Fields Modifier and Type Field Description static Dimension.Model
STANDARD
Holds the standard model (default).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Dimension
getDimension(BaseUnit<?> unit)
Returns the dimension of the specified base unit (a dimension particular to the base unit if the base unit is not recognized).UnitConverter
getTransform(BaseUnit<?> unit)
Returns the normalization transform of the specified base unit (IDENTITY
if the base unit is not recognized).
-
-
-
Field Detail
-
STANDARD
static final Dimension.Model STANDARD
Holds the standard model (default).
-
-
Method Detail
-
getDimension
Dimension getDimension(BaseUnit<?> unit)
Returns the dimension of the specified base unit (a dimension particular to the base unit if the base unit is not recognized).- Parameters:
unit
- the base unit for which the dimension is returned.- Returns:
- the dimension of the specified unit.
-
getTransform
UnitConverter getTransform(BaseUnit<?> unit)
Returns the normalization transform of the specified base unit (IDENTITY
if the base unit is not recognized).- Parameters:
unit
- the base unit for which the transform is returned.- Returns:
- the normalization transform.
-
-