javax.measure.unit
public class BaseUnit<Q extends Quantity> extends Unit<Q>
This class represents the building blocks on top of which all others units are created. Base units are typically
dimensionally independent. The actual unit dimension is determinated by the current model
.
For example using the standard
model, SI.CANDELA
has the dimension of
watt
:
// Standard model.
BaseUnit<Length> METER = new BaseUnit<Length>("m");
BaseUnit<LuminousIntensity> CANDELA = new BaseUnit<LuminousIntensity>("cd");
System.out.println(METER.getDimension());
System.out.println(CANDELA.getDimension());
> [L] > [L]²·[M]/[T]³
This class represents the "standard base units" which includes SI base units and possibly others user-defined base
units. It does not represent the base units of any specific SystemOfUnits
(they would have be base units
accross all possible systems otherwise).
Constructor and Description |
---|
BaseUnit(java.lang.String symbol)
Creates a base unit having the specified symbol.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object that)
Indicates if this base unit is considered equals to the specified object (both are base units with equal symbol,
standard dimension and standard transform).
|
Unit<? super Q> |
getStandardUnit()
Returns the
base unit , alternate unit or product of base units and
alternate units this unit is derived from. |
java.lang.String |
getSymbol()
Returns the unique symbol for this base unit.
|
int |
hashCode()
Returns the hash code for this unit.
|
UnitConverter |
toStandardUnit()
Returns the converter from this unit to its system unit.
|
public BaseUnit(java.lang.String symbol)
symbol
- the symbol of this base unit.java.lang.IllegalArgumentException
- if the specified symbol is associated to a different unit.public final java.lang.String getSymbol()
public boolean equals(java.lang.Object that)
public int hashCode()
Unit
public Unit<? super Q> getStandardUnit()
Unit
base unit
, alternate unit
or product of base units and
alternate units this unit is derived from. The standard unit identifies the "type" of
quantity
for which this unit is employed. For example:
boolean isAngularVelocity(Unit<?> u) { return u.getStandardUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity());
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).
getStandardUnit
in class Unit<Q extends Quantity>
public UnitConverter toStandardUnit()
Unit
toStandardUnit
in class Unit<Q extends Quantity>
this.getConverterTo(this.getSystemUnit())