public final class AlternateUnit<Q extends javax.measure.Quantity<Q>> extends AbstractUnit<Q>
This class represents units used in expressions to distinguish between quantities of a different nature but of the same dimensions.
Examples of alternate units:
Unit<Angle> RADIAN = AlternateUnit.of(ONE, "rad").asType(Angle.class);
Unit<Force> NEWTON = AlternateUnit.of(METRE.multiply(KILOGRAM).divide(SECOND.pow(2)), "N").asType(Force.class);
Unit<Pressure> PASCAL = AlternateUnit.of(NEWTON.divide(METRE.pow(2), "Pa").asType(Pressure.class);
AbstractUnit.Equalizername, ONE, SYMBOL_TO_UNIT| Constructor and Description |
|---|
AlternateUnit(javax.measure.Unit<?> parentUnit,
String symbol)
Creates an alternate unit for the specified system unit identified by the
specified name and symbol.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Map<? extends javax.measure.Unit<?>,Integer> |
getBaseUnits() |
javax.measure.Dimension |
getDimension() |
javax.measure.Unit<?> |
getParentUnit()
Returns the parent unit of this alternate unit, always a system unit and
never an alternate unit.
|
javax.measure.UnitConverter |
getSystemConverter()
Returns the converter from this unit to its unscaled
System Unit unit. |
int |
hashCode() |
static <Q extends javax.measure.Quantity<Q>> |
of(javax.measure.Unit<?> parent,
String symbol)
Creates an alternate unit for the specified system unit identified by the specified name and symbol.
|
static <Q extends javax.measure.Quantity<Q>> |
of(javax.measure.Unit<?> parent,
String symbol,
String name)
Creates an alternate unit for the specified system unit identified by the specified name and symbol.
|
javax.measure.Unit<Q> |
toSystemUnit()
Returns the unscaled
SI unit from which this unit is derived. |
alternate, annotate, asType, compareTo, divide, divide, divide, getActualType, getConverterTo, getConverterToAny, getName, getSymbol, getSystemUnit, internalGetConverterTo, inverse, isCompatible, isEquivalentTo, isSystemUnit, multiply, multiply, multiply, parse, pow, prefix, root, setName, setSymbol, shift, shift, toString, transformpublic AlternateUnit(javax.measure.Unit<?> parentUnit, String symbol)
parentUnit - the system unit from which this alternate unit is derived.symbol - the symbol for this alternate unit.IllegalArgumentException - if the specified parent unit is not an
system
unitpublic javax.measure.Unit<?> getParentUnit()
public javax.measure.Dimension getDimension()
getDimension in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>getDimension in class AbstractUnit<Q extends javax.measure.Quantity<Q>>public javax.measure.UnitConverter getSystemConverter()
AbstractUnitSystem Unit unit.getSystemConverter in class AbstractUnit<Q extends javax.measure.Quantity<Q>>getConverterTo(this.toSystemUnit())AbstractUnit.toSystemUnit()public javax.measure.Unit<Q> toSystemUnit()
AbstractUnitSI unit 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. toSystemUnit in class AbstractUnit<Q extends javax.measure.Quantity<Q>>public Map<? extends javax.measure.Unit<?>,Integer> getBaseUnits()
getBaseUnits in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>getBaseUnits in class AbstractUnit<Q extends javax.measure.Quantity<Q>>public int hashCode()
hashCode in class AbstractUnit<Q extends javax.measure.Quantity<Q>>public boolean equals(Object obj)
equals in class AbstractUnit<Q extends javax.measure.Quantity<Q>>public static <Q extends javax.measure.Quantity<Q>> AlternateUnit<Q> of(javax.measure.Unit<?> parent, String symbol)
parent - the system unit from which this alternate unit is derived.symbol - the symbol for this alternate unit.IllegalArgumentException - if the specified parent unit is not an unscaled standard system unit.MeasurementException - if the specified symbol is not valid or is already associated to a different unit.public static <Q extends javax.measure.Quantity<Q>> AlternateUnit<Q> of(javax.measure.Unit<?> parent, String symbol, String name)
parent - the system unit from which this alternate unit is derived.symbol - the symbol for this alternate unit.name - the name for this alternate unit.IllegalArgumentException - if the specified parent unit is not an unscaled standard system unit.MeasurementException - if the specified symbol is not valid or is already associated to a different unit.Copyright © 2005–2021 Units of Measurement project. All rights reserved.