public abstract class AbstractQuantity<Q extends javax.measure.Quantity<Q>> extends Object implements javax.measure.Quantity<Q>, tech.uom.lib.common.function.QuantityConverter<Q>, Comparable<javax.measure.Quantity<Q>>
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractQuantity()
Constructor.
|
protected |
AbstractQuantity(javax.measure.Quantity.Scale scale)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends javax.measure.Quantity<T>> |
asType(Class<T> type)
Casts this quantity to a parameterized quantity of specified nature or throw a
ClassCastException if the dimension of the specified
quantity and its unit's dimension do not match. |
protected abstract boolean |
eq(AbstractQuantity<Q> dq) |
boolean |
equals(Object o) |
protected abstract Number |
getScalar() |
javax.measure.Quantity.Scale |
getScale()
Returns the measurement level.
|
protected String |
getStr(Number val,
int precision) |
int |
hashCode()
Returns the hash code for this measure.
|
boolean |
isEquivalentTo(javax.measure.Quantity<Q> that) |
protected abstract boolean |
isZero() |
protected String |
showInUnit(javax.measure.Unit<?> u,
Double s,
int precision,
UnitStyle style) |
protected String |
showInUnit(javax.measure.Unit<?> u,
int precision) |
protected abstract String |
showInUnit(javax.measure.Unit<?> u,
int precision,
UnitStyle style) |
protected String |
showInUnit(javax.measure.Unit<?> u,
Number s,
int precision,
UnitStyle style,
boolean withSpace) |
String |
toString() |
protected String |
toString(boolean withSpace) |
String |
toString(boolean withUnit,
boolean withSpace) |
abstract String |
toString(boolean withUnit,
boolean withSpace,
int precision) |
protected String |
toString(int precision) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, divide, divide, getUnit, getValue, inverse, multiply, multiply, negate, subtract, to, toSystemUnitcompareToprotected AbstractQuantity(javax.measure.Quantity.Scale scale)
scale - a scale of measurementprotected AbstractQuantity()
protected abstract boolean eq(AbstractQuantity<Q> dq)
protected abstract boolean isZero()
public boolean isEquivalentTo(javax.measure.Quantity<Q> that)
public javax.measure.Quantity.Scale getScale()
public int hashCode()
public final <T extends javax.measure.Quantity<T>> AbstractQuantity<T> asType(Class<T> type) throws ClassCastException
ClassCastException if the dimension of the specified
quantity and its unit's dimension do not match. For
example:
Quantity length = BaseQuantity.of("2 km").asType(Length.class);
asType in interface javax.measure.Quantity<Q extends javax.measure.Quantity<Q>>type - the quantity class identifying the nature of the measure.ClassCastException - if the dimension of this unit is different
from the specified quantity dimension.UnsupportedOperationException - if the specified quantity class does not have a public static
field named "UNIT" holding the SI unit for the quantity.Unit.asType(Class)protected abstract String showInUnit(javax.measure.Unit<?> u, int precision, UnitStyle style)
protected String showInUnit(javax.measure.Unit<?> u, Number s, int precision, UnitStyle style, boolean withSpace)
protected String showInUnit(javax.measure.Unit<?> u, Double s, int precision, UnitStyle style)
protected String showInUnit(javax.measure.Unit<?> u, int precision)
u - precision - number of decimal placesCopyright © 2005–2024 Units of Measurement project. All rights reserved.