Q - the type of the Quantity resultpublic interface QuantityFactory<Q extends Quantity<Q>>
Quantity,
Unit| Modifier and Type | Method | Description |
|---|---|---|
Quantity<Q> |
create(Number value,
Unit<Q> unit) |
Returns the quantity for the specified number stated in the specified unit.
|
Quantity<Q> |
create(Number value,
Unit<Q> unit,
Quantity.Scale scale) |
Returns the quantity for the specified number stated in the specified unit and scale.
|
Unit<Q> |
getSystemUnit() |
Returns the system unit for quantities produced by this factory or
null if unknown. |
Quantity<Q> create(Number value, Unit<Q> unit, Quantity.Scale scale)
value - the numeric value stated in the specified unitunit - the unitscale - The ABSOLUTE / RELATIVE scale of this quantityQuantity<Q> create(Number value, Unit<Q> unit)
value - the numeric value stated in the specified unitunit - the unitUnit<Q> getSystemUnit()
null if unknown.
Because the system unit is unique by quantity type, it can be be used to identify the quantity given the unit. For example:
static boolean isAngularSpeed(Unit<?> unit) {
return unit.getSystemUnit().equals(RADIAN.divide(SECOND));
}
assert isAngularSpeed(REVOLUTION.divide(MINUTE)); // Returns true.
Unit.getSystemUnit()Copyright © 2014–2019 Jean-Marie Dautelle, Werner Keil, Otavio Santana. All rights reserved.