public final class Quantities extends Static
Quantity instances.
Apache SIS implementation of quantities has the following characteristics:
double precision.Length instead of Quantity<Length>).Comparable and Serializable.Defined in the sis-utility module
| Modifier and Type | Method and Description |
|---|---|
static <Q extends Quantity<Q>> |
castOrCopy(Quantity<Q> quantity)
Returns the given quantity as an instance of the specific
Quantity subtype. |
static Quantity<?> |
create(double value,
String unit)
Creates a quantity for the given value and unit of measurement symbol.
|
static <Q extends Quantity<Q>> |
create(double value,
Unit<Q> unit)
Creates a quantity for the given value and unit of measurement.
|
public static Quantity<?> create(double value, String unit)
Units.valueOf(String)
with create(double, Unit).value - the quantity magnitude.unit - symbol of the unit of measurement associated to the given value.ParserException - if the given symbol can not be parsed.public static <Q extends Quantity<Q>> Q create(double value, Unit<Q> unit)
Q - the quantity type (e.g. Length, Angle, Time, etc.).value - the quantity magnitude.unit - the unit of measurement associated to the given value.IllegalArgumentException - if the given unit class is not a supported implementation.UnitServices.getQuantityFactory(Class)public static <Q extends Quantity<Q>> Q castOrCopy(Quantity<Q> quantity)
Quantity subtype.
For example this method can be used for converting a Quantity<Length> to a Length.
If the given quantity already implements the specific interface, then it is returned as-is.Q - the quantity type (e.g. Length, Angle, Time, etc.), or null.quantity - the quantity to convert to the specific subtype.quantity itself), or null if the given quantity was null.IllegalArgumentException - if the unit class associated to the given quantity is not a supported implementation.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.