Package tech.units.indriya.unit
Class TransformedUnit<Q extends Quantity<Q>>
- java.lang.Object
-
- tech.units.indriya.AbstractUnit<Q>
-
- tech.units.indriya.unit.TransformedUnit<Q>
-
- Type Parameters:
Q- The type of the quantity measured by this unit.
- All Implemented Interfaces:
Serializable,Comparable<Unit<Q>>,Unit<Q>,tech.uom.lib.common.function.Nameable,tech.uom.lib.common.function.PrefixOperator<Q>,tech.uom.lib.common.function.SymbolSupplier,tech.uom.lib.common.function.UnitConverterSupplier
public final class TransformedUnit<Q extends Quantity<Q>> extends AbstractUnit<Q> implements tech.uom.lib.common.function.UnitConverterSupplier
This class represents the units derived from other units using converters.
Examples of transformed units:
CELSIUS = KELVIN.shift(273.15); FOOT = METRE.multiply(3048).divide(10000); MILLISECOND = MILLI(SECOND);Transformed units have no symbol. But like any other units, they may have labels attached to them (see
UnitFormat.labelInstances of this class are created through the
AbstractUnit.transform(javax.measure.UnitConverter)method.- Since:
- 1.0
- Version:
- 2.0, March 1, 2020
- Author:
- Jean-Marie Dautelle, Werner Keil
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractUnit
AbstractUnit.Equalizer
-
-
Field Summary
-
Fields inherited from class tech.units.indriya.AbstractUnit
ONE, scale, SYMBOL_TO_UNIT
-
-
Constructor Summary
Constructors Constructor Description TransformedUnit(String symbol, String name, Unit<Q> parentUnit, Unit<Q> sysUnit, UnitConverter unitConverter)Creates a transformed unit from the specified parent and system unit. using a specific symbol and name.TransformedUnit(String symbol, String name, Unit<Q> parentUnit, UnitConverter unitConverter)Creates a transformed unit from the specified parent unit.TransformedUnit(String symbol, Unit<Q> parentUnit, Unit<Q> sysUnit, UnitConverter unitConverter)Creates a transformed unit from the specified parent and system unit. using a specific symbol.TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter)Creates a transformed unit from the specified parent unit.TransformedUnit(Unit<Q> parentUnit, UnitConverter unitConverter)Creates a transformed unit from the specified system unit. using the parent as symbol
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Map<? extends Unit<?>,Integer>getBaseUnits()UnitConvertergetConverter()Returns the converter to the parent unit.DimensiongetDimension()Unit<Q>getParentUnit()Returns the parent unit for this unit.UnitConvertergetSystemConverter()Returns the converter from this unit to its unscaledSystem Unitunit.inthashCode()protected Unit<Q>toSystemUnit()Returns the unscaledSIunit from which this unit is derived.-
Methods inherited from class tech.units.indriya.AbstractUnit
alternate, annotate, asType, compareTo, divide, divide, divide, getActualType, getConverterTo, getConverterTo, getConverterToAny, getConverterToAny, getName, getSymbol, getSystemUnit, internalGetConverterTo, inverse, isCompatible, isEquivalentTo, isSystemUnit, multiply, multiply, multiply, parse, pow, prefix, root, setName, setSymbol, shift, shift, toString, transform
-
-
-
-
Constructor Detail
-
TransformedUnit
public TransformedUnit(Unit<Q> parentUnit, UnitConverter unitConverter)
Creates a transformed unit from the specified system unit. using the parent as symbol- Parameters:
parentUnit- the system unit from which this unit is derived.converter- the converter to the parent units.
-
TransformedUnit
public TransformedUnit(String symbol, String name, Unit<Q> parentUnit, UnitConverter unitConverter)
Creates a transformed unit from the specified parent unit.- Parameters:
symbol- the symbol to use with this transformed unit.name- the name to use with this transformed unit.parentUnit- the parent unit from which this unit is derived.unitConverter- the converter to the parent units.- Since:
- 2.0
-
TransformedUnit
public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter)
Creates a transformed unit from the specified parent unit.- Parameters:
symbol- the symbol to use with this transformed unit.parentUnit- the parent unit from which this unit is derived.unitConverter- the converter to the parent units.
-
TransformedUnit
public TransformedUnit(String symbol, String name, Unit<Q> parentUnit, Unit<Q> sysUnit, UnitConverter unitConverter)
Creates a transformed unit from the specified parent and system unit. using a specific symbol and name.- Parameters:
symbol- the symbol for this unit.name- the name for this unit.parentUnit- the parent unit from which this unit is derived.sysUnit- the system unit which this unit is based on.converter- the converter to the parent units.- Since:
- 2.0
-
TransformedUnit
public TransformedUnit(String symbol, Unit<Q> parentUnit, Unit<Q> sysUnit, UnitConverter unitConverter)
Creates a transformed unit from the specified parent and system unit. using a specific symbol.- Parameters:
symbol- the symbol for this unit.parentUnit- the parent unit from which this unit is derived.sysUnit- the system unit which this unit is based on.converter- the converter to the parent units.
-
-
Method Detail
-
getDimension
public Dimension getDimension()
- Specified by:
getDimensionin interfaceUnit<Q extends Quantity<Q>>- Specified by:
getDimensionin classAbstractUnit<Q extends Quantity<Q>>
-
getSystemConverter
public UnitConverter getSystemConverter()
Description copied from class:AbstractUnitReturns the converter from this unit to its unscaledSystem Unitunit.- Specified by:
getSystemConverterin classAbstractUnit<Q extends Quantity<Q>>- Returns:
getConverterTo(this.toSystemUnit())- See Also:
AbstractUnit.toSystemUnit()
-
getConverter
public UnitConverter getConverter()
Returns the converter to the parent unit.- Specified by:
getConverterin interfacetech.uom.lib.common.function.UnitConverterSupplier- Returns:
- the converter to the parent unit.
-
toSystemUnit
protected Unit<Q> toSystemUnit()
Description copied from class:AbstractUnitReturns the unscaledSIunit from which this unit is derived. The SI unit can be be used to identify a quantity given the unit. For example:static boolean isAngularVelocity(AbstractUnit> unit) { return unit.toSystemUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); // Returns true.- Specified by:
toSystemUnitin classAbstractUnit<Q extends Quantity<Q>>- Returns:
- the unscaled metric unit from which this unit is derived.
-
getBaseUnits
public Map<? extends Unit<?>,Integer> getBaseUnits()
- Specified by:
getBaseUnitsin interfaceUnit<Q extends Quantity<Q>>- Specified by:
getBaseUnitsin classAbstractUnit<Q extends Quantity<Q>>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin classAbstractUnit<Q extends Quantity<Q>>
-
getParentUnit
public Unit<Q> getParentUnit()
Returns the parent unit for this unit. The parent unit is the untransformed unit from which this unit is derived.- Returns:
- the untransformed unit from which this unit is derived.
-
-