Package net.solarnetwork.javax.measure
Interface MeasurementServiceProvider
- All Known Implementing Classes:
DelegateMeasurementServiceProvider,IndriyaMeasurementServiceProvider
public interface MeasurementServiceProvider
API for interacting with Units of Measurement services.
- Version:
- 1.0
- Author:
- matt
-
Method Summary
Modifier and TypeMethodDescriptionjavax.measure.spi.FormatServiceReturns the service to obtainUnitFormatandQuantityFormatornullif none.<Q extends javax.measure.Quantity<Q>>
javax.measure.spi.QuantityFactory<Q>getQuantityFactory(Class<Q> quantity) Returns a factory for the givenQuantitytype.javax.measure.spi.SystemOfUnitsServiceReturns the service to obtain aSystemOfUnits, ornullif none.javax.measure.spi.UnitFormatServiceReturns the service to obtain aUnitFormat, ornullif none.<Q extends javax.measure.Quantity<Q>>
javax.measure.Quantity<Q>quantityForUnit(Number value, javax.measure.Unit<Q> unit) Get a quantity for a given number and unit.
-
Method Details
-
getSystemOfUnitsService
javax.measure.spi.SystemOfUnitsService getSystemOfUnitsService()Returns the service to obtain aSystemOfUnits, ornullif none.- Returns:
- the service to obtain a
SystemOfUnits, ornull.
-
getFormatService
javax.measure.spi.FormatService getFormatService()Returns the service to obtainUnitFormatandQuantityFormatornullif none.- Returns:
- the service to obtain a
UnitFormatandQuantityFormat, ornull.
-
getUnitFormatService
javax.measure.spi.UnitFormatService getUnitFormatService()Returns the service to obtain aUnitFormat, ornullif none.This API is deprecated in
javax.measure2.0, but the reference implementation exposes some parsing features only through this API (UCUM) so it is repeated here.- Returns:
- the service to obtain a
UnitFormat, ornull.
-
getQuantityFactory
<Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getQuantityFactory(Class<Q> quantity) Returns a factory for the givenQuantitytype.- Type Parameters:
Q- the type of theQuantityinstances created by the factory- Parameters:
quantity- the quantity type- Returns:
- the
QuantityFactoryfor the given type
-
quantityForUnit
<Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> quantityForUnit(Number value, javax.measure.Unit<Q> unit) Get a quantity for a given number and unit.- Type Parameters:
Q- the quantity type- Parameters:
value- the quantity amountunit- the quantity unit- Returns:
- the quantity, or
nullif one cannot be obtained
-