Package tech.units.indriya.quantity
Class Quantities
- java.lang.Object
-
- tech.units.indriya.quantity.Quantities
-
public final class Quantities extends java.lang.ObjectSingleton class for accessingQuantityinstances.- Since:
- 1.0
- Version:
- 1.1
-
-
Constructor Summary
Constructors Modifier Constructor Description privateQuantities()Private singleton constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ComparableQuantity<?>getQuantity(java.lang.CharSequence csq)Returns thedecimalquantity of unknown type corresponding to the specified representation.static <Q extends javax.measure.Quantity<Q>>
ComparableQuantity<Q>getQuantity(java.lang.Number value, javax.measure.Unit<Q> unit)Returns the scalar measurement.
-
-
-
Method Detail
-
getQuantity
public static ComparableQuantity<?> getQuantity(java.lang.CharSequence csq)
Returns thedecimalquantity of unknown type corresponding to the specified representation. This method can be used to parse dimensionless quantities.
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(java.lang.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:
java.lang.NullPointerException- when value or unit were null
-
-