Package tech.units.indriya.unit
Class TransformedUnit<Q extends javax.measure.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:
java.io.Serializable,java.lang.Comparable<javax.measure.Unit<Q>>,javax.measure.Unit<Q>,ComparableUnit<Q>,tech.uom.lib.common.function.UnitConverterSupplier
public final class TransformedUnit<Q extends javax.measure.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:
- 1.2, August 06, 2017
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractUnit
AbstractUnit.Equalizer
-
-
Field Summary
Fields Modifier and Type Field Description private javax.measure.UnitConverterconverterHolds the converter to the parent unit.private AbstractUnit<Q>parentUnitHolds the parent unit.private static longserialVersionUIDprivate java.lang.StringsymbolHolds the symbol.private javax.measure.Unit<Q>systemUnitHolds the system unit.-
Fields inherited from class tech.units.indriya.AbstractUnit
name, ONE, SYMBOL_TO_UNIT
-
-
Constructor Summary
Constructors Constructor Description TransformedUnit(java.lang.String symbol, javax.measure.Unit<Q> parentUnit, javax.measure.Unit<Q> sysUnit, javax.measure.UnitConverter unitConverter)Creates a transformed unit from the specified parent and system unit.TransformedUnit(java.lang.String symbol, javax.measure.Unit<Q> parentUnit, javax.measure.UnitConverter unitConverter)Creates a transformed unit from the specified parent unit.TransformedUnit(javax.measure.Unit<Q> parentUnit, javax.measure.UnitConverter unitConverter)Creates a transformed unit from the specified system unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.Map<? extends javax.measure.Unit<?>,java.lang.Integer>getBaseUnits()javax.measure.UnitConvertergetConverter()Returns the converter to the parent unit.javax.measure.DimensiongetDimension()javax.measure.Unit<Q>getParentUnit()Returns the parent unit for this unit.java.lang.StringgetSymbol()javax.measure.UnitConvertergetSystemConverter()Returns the converter from this unit to its unscaledSystem Unitunit.inthashCode()protected javax.measure.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, getConverterToAny, getName, getSystemUnit, inverse, isCompatible, isEquivalentOf, isSystemUnit, multiply, multiply, multiply, parse, pow, prefix, root, setName, setSymbol, shift, toString, transform
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
parentUnit
private final AbstractUnit<Q extends javax.measure.Quantity<Q>> parentUnit
Holds the parent unit.
-
systemUnit
private final javax.measure.Unit<Q extends javax.measure.Quantity<Q>> systemUnit
Holds the system unit.
-
converter
private final javax.measure.UnitConverter converter
Holds the converter to the parent unit.
-
symbol
private java.lang.String symbol
Holds the symbol.
-
-
Constructor Detail
-
TransformedUnit
public TransformedUnit(javax.measure.Unit<Q> parentUnit, javax.measure.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(java.lang.String symbol, javax.measure.Unit<Q> parentUnit, javax.measure.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(java.lang.String symbol, javax.measure.Unit<Q> parentUnit, javax.measure.Unit<Q> sysUnit, javax.measure.UnitConverter unitConverter)Creates a transformed unit from the specified parent and system unit. using the parent as symbol- Parameters:
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 javax.measure.Dimension getDimension()
- Specified by:
getDimensionin interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>- Specified by:
getDimensionin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
getSystemConverter
public javax.measure.UnitConverter getSystemConverter()
Description copied from class:AbstractUnitReturns the converter from this unit to its unscaledSystem Unitunit.- Specified by:
getSystemConverterin classAbstractUnit<Q extends javax.measure.Quantity<Q>>- Returns:
getConverterTo(this.toSystemUnit())- See Also:
AbstractUnit.toSystemUnit()
-
getConverter
public javax.measure.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 javax.measure.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 javax.measure.Quantity<Q>>- Returns:
- the unscaled metric unit from which this unit is derived.
-
getBaseUnits
public java.util.Map<? extends javax.measure.Unit<?>,java.lang.Integer> getBaseUnits()
- Specified by:
getBaseUnitsin interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>- Specified by:
getBaseUnitsin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
hashCode
public int hashCode()
- Specified by:
hashCodein classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
getSymbol
public java.lang.String getSymbol()
-
getParentUnit
public javax.measure.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.
-
-