public final class Quantities extends Object
Quantity instances.| Modifier and Type | Method | Description |
|---|---|---|
static <Q extends javax.measure.Quantity<Q>> |
getCompoundQuantity(Number[] values,
javax.measure.Unit<Q>[] units) |
Returns the mixed radix values and units as
CompoundQuantity in the
ABSOLUTE scale. |
static <Q extends javax.measure.Quantity<Q>> |
getCompoundQuantity(Number[] values,
javax.measure.Unit<Q>[] units,
javax.measure.Quantity.Scale scale) |
Returns the mixed radix values and units as
CompoundQuantity in the
specified scale. |
static javax.measure.Quantity<?> |
getQuantity(CharSequence csq) |
Returns the
decimal quantity of unknown type corresponding to the specified
representation. |
static <Q extends javax.measure.Quantity<Q>> |
getQuantity(Number[] values,
javax.measure.Unit<Q>... units) |
Returns the mixed radix values and units combined into a single quantity in
the
ABSOLUTE scale. |
static <Q extends javax.measure.Quantity<Q>> |
getQuantity(Number[] values,
javax.measure.Unit<Q>[] units,
javax.measure.Quantity.Scale scale) |
Returns the mixed radix values and units combined into a single quantity.
|
static <Q extends javax.measure.Quantity<Q>> |
getQuantity(Number value,
javax.measure.Unit<Q> unit) |
Returns the scalar quantity.
|
static <Q extends javax.measure.Quantity<Q>> |
getQuantity(Number value,
javax.measure.Unit<Q> unit,
javax.measure.Quantity.Scale scale) |
Returns the scalar quantity.
|
public static javax.measure.Quantity<?> getQuantity(CharSequence csq)
decimal quantity of unknown type corresponding to the specified
representation. This method can be used to parse dimensionless
quantities.
Quantity proportion = Quantities.getQuantity("0.234").asType(Dimensionless.class);
Note: This method handles only Locale-neutral quantity formatting and parsing
are handled by the AbstractQuantityFormat class and its subclasses.
csq - the decimal value and its unit (if any) separated by space(s).QuantityFormat.getInstance(LOCALE_NEUTRAL).parse(csq)public static <Q extends javax.measure.Quantity<Q>> ComparableQuantity<Q> getQuantity(Number value, javax.measure.Unit<Q> unit, javax.measure.Quantity.Scale scale)
Number was BigDecimal
or BigInteger will uses DecimalQuantity, when the
Number was Double will DoubleQuantity otherwise will
NumberQuantity. in the specified unit.value - the measurement value.unit - the measurement unit.scale - the measurement scale.numeric quantity.NullPointerException - if value, unit or scale were nulljavax.measure.MeasurementException - if unit is a MixedUnitpublic static <Q extends javax.measure.Quantity<Q>> ComparableQuantity<Q> getQuantity(Number value, javax.measure.Unit<Q> unit)
Number was BigDecimal
or BigInteger will uses DecimalQuantity, when the
Number was Double will DoubleQuantity otherwise will
NumberQuantity. in the specified unit.value - the measurement value.unit - the measurement unit.numeric quantity.NullPointerException - when value or unit were nullpublic static <Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> getQuantity(Number[] values, javax.measure.Unit<Q>[] units, javax.measure.Quantity.Scale scale)
Number was BigDecimal or BigInteger will
uses DecimalQuantity, when the Number was Double will
DoubleQuantity otherwise will NumberQuantity. in the
specified unit.values - the measurement values.units - the measurement units.scale - the measurement scale.NullPointerException - if value or scale were nullIllegalArgumentException - if the size of the values array does not
match that of units.@SafeVarargs public static <Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> getQuantity(Number[] values, javax.measure.Unit<Q>... units)
ABSOLUTE scale.values - the measurement values.units - the measurement units.NullPointerException - if value or unit were nullIllegalArgumentException - if the size of the values array does not
match that of units.public static <Q extends javax.measure.Quantity<Q>> CompoundQuantity<Q> getCompoundQuantity(Number[] values, javax.measure.Unit<Q>[] units, javax.measure.Quantity.Scale scale)
CompoundQuantity in the
specified scale.values - the measurement values.units - the measurement units.scale - the measurement scale.NullPointerException - if values, units or scale were nullIllegalArgumentException - if the size of the values array does not
match that of units.public static <Q extends javax.measure.Quantity<Q>> CompoundQuantity<Q> getCompoundQuantity(Number[] values, javax.measure.Unit<Q>[] units)
CompoundQuantity in the
ABSOLUTE scale.values - the measurement values.units - the measurement units.NullPointerException - if values, units or scale were nullIllegalArgumentException - if the size of the values array does not
match that of units.Copyright © 2005–2020 Units of Measurement project. All rights reserved.