Class TransformedUnit<Q extends Quantity>
- java.lang.Object
-
- javax.measure.unit.Unit<Q>
-
- javax.measure.unit.DerivedUnit<Q>
-
- javax.measure.unit.TransformedUnit<Q>
-
- All Implemented Interfaces:
Serializable
public final class TransformedUnit<Q extends Quantity> extends DerivedUnit<Q>
This class represents the units derived from other units using
converters.Examples of transformed units:[code] CELSIUS = KELVIN.add(273.15); FOOT = METER.multiply(0.3048); MILLISECOND = MILLI(SECOND); [/code]
Transformed units have no label. But like any other units, they may have labels attached to them:[code] UnitFormat.getStandardInstance().label(FOOT, "ft"); [/code] or aliases: [code] UnitFormat.getStandardInstance().alias(CENTI(METER)), "centimeter"); UnitFormat.getStandardInstance().alias(CENTI(METER)), "centimetre"); [/code]
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object that)Indicates if this transformed unit is considered equals to the specified object (both are transformed units with equal parent unit and equal converter to parent unit).Unit<Q>getParentUnit()Returns the parent unit for this unit.Unit<? super Q>getStandardUnit()Returns thebase unit,alternate unitor product of base units and alternate units this unit is derived from.inthashCode()Returns the hash code for this unit.UnitConvertertoParentUnit()Returns the converter to the parent unit.UnitConvertertoStandardUnit()Returns the converter from this unit to its system unit.
-
-
-
Method Detail
-
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.
-
toParentUnit
public UnitConverter toParentUnit()
Returns the converter to the parent unit.- Returns:
- the converter to the parent unit.
-
equals
public boolean equals(Object that)
Indicates if this transformed unit is considered equals to the specified object (both are transformed units with equal parent unit and equal converter to parent unit).
-
hashCode
public int hashCode()
Description copied from class:UnitReturns the hash code for this unit.
-
getStandardUnit
public Unit<? super Q> getStandardUnit()
Description copied from class:UnitReturns thebase unit,alternate unitor product of base units and alternate units this unit is derived from. The standard unit identifies the "type" ofquantityfor which this unit is employed. For example:[code] boolean isAngularVelocity(Unit> u) { return u.getStandardUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); [/code]Note: Having the same system unit is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).
- Specified by:
getStandardUnitin classUnit<Q extends Quantity>- Returns:
- the system unit this unit is derived from.
-
toStandardUnit
public UnitConverter toStandardUnit()
Description copied from class:UnitReturns the converter from this unit to its system unit.- Specified by:
toStandardUnitin classUnit<Q extends Quantity>- Returns:
this.getConverterTo(this.getSystemUnit())
-
-