Top Description Methods
javax.measure.spi

public Interface QuantityFactory<Q extends javax.measure.Quantity<Q>>

Type Parameters
<Q>
the type of the Quantity result
Imports
javax.measure.Quantity, .Quantity.Scale, .Unit

Represents a factory that accepts Number and Unit arguments to create Quantity results.
Authors
Werner Keil, Otavio Santana
Since
1.0
Version
1.4, December 18, 2018
See Also
Wikipedia: Factory method pattern, Quantity, Unit

Method Summary

Modifier and TypeMethod and Description
public Quantity<Q>

Returns:

the corresponding quantity
create
(Number
the numeric value stated in the specified unit
value
,
Unit<Q>
the unit
unit
,
Quantity.Scale
The ABSOLUTE / RELATIVE scale of this quantity
scale
)

Returns the quantity for the specified number stated in the specified unit and scale.

public Quantity<Q>

Returns:

the corresponding quantity
create
(Number
the numeric value stated in the specified unit
value
,
Unit<Q>
the unit
unit
)

Returns the quantity for the specified number stated in the specified unit.

public Unit<Q>

Returns:

the system unit for this factory.
getSystemUnit
()

Returns the system unit for quantities produced by this factory or null if unknown.

Method Detail

createback to summary
public Quantity<Q> create(Number value, Unit<Q> unit, Quantity.Scale scale)

Returns the quantity for the specified number stated in the specified unit and scale.

Parameters
value:Number

the numeric value stated in the specified unit

unit:Unit<Q>

the unit

scale:Quantity.Scale

The ABSOLUTE / RELATIVE scale of this quantity

Returns:Quantity<Q>

the corresponding quantity

Since
2.0
createback to summary
public Quantity<Q> create(Number value, Unit<Q> unit)

Returns the quantity for the specified number stated in the specified unit.

Parameters
value:Number

the numeric value stated in the specified unit

unit:Unit<Q>

the unit

Returns:Quantity<Q>

the corresponding quantity

getSystemUnitback to summary
public Unit<Q> getSystemUnit()

Returns the system unit for quantities produced by this factory or null if unknown.

Because the system unit is unique by quantity type, it can be be used to identify the quantity given the unit. For example:

    static boolean isAngularSpeed(Unit<?> unit) {
        return unit.getSystemUnit().equals(RADIAN.divide(SECOND));
    }
    assert isAngularSpeed(REVOLUTION.divide(MINUTE)); // Returns true.
Returns:Unit<Q>

the system unit for this factory.

See Also
Unit#getSystemUnit()