Class Quantities
java.lang.Object
tech.units.indriya.quantity.Quantities
Singleton class for accessing
Quantity instances.- Since:
- 1.0
- Version:
- 1.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComparableQuantity<?> getQuantity(CharSequence csq) Returns thequantity of unknown type corresponding to the specified representation.invalid reference
decimalstatic <Q extends javax.measure.Quantity<Q>>
ComparableQuantity<Q> getQuantity(Number value, javax.measure.Unit<Q> unit) Returns the scalar measurement.
-
Constructor Details
-
Quantities
private Quantities()Private singleton constructor.
-
-
Method Details
-
getQuantity
Returns thequantity of unknown type corresponding to the specified representation. This method can be used to parse dimensionless quantities.invalid reference
decimal
Quantityproportion = Quantities.getQuantity("0.234").asType(Dimensionless.class); Note: This method handles only Locale-neutral quantity formatting and parsing are handled by the
AbstractQuantityFormatclass and its subclasses.- Parameters:
csq- the decimal value and its unit (if any) separated by space(s).- Returns:
QuantityFormat.getInstance(LOCALE_NEUTRAL).parse(csq, new ParsePosition(0))
-
getQuantity
public static <Q extends javax.measure.Quantity<Q>> ComparableQuantity<Q> getQuantity(Number value, javax.measure.Unit<Q> unit) Returns the scalar measurement. When theNumberwasBigDecimalorBigIntegerwill usesDecimalQuantity, when theNumberwasDoublewillDoubleQuantityotherwise willNumberQuantity. in the specified unit.- Parameters:
value- the measurement value.unit- the measurement unit.- Returns:
- the corresponding
numericmeasurement. - Throws:
NullPointerException- when value or unit were null
-