public class DefaultServiceProvider
extends javax.measure.spi.ServiceProvider
implements java.lang.Comparable<javax.measure.spi.ServiceProvider>
ServiceProvider
class and
hereby uses the JDK ServiceLoader
to load the required
services.Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Class,javax.measure.spi.QuantityFactory> |
QUANTITY_FACTORIES |
private static java.util.Comparator<java.lang.Object> |
SERVICE_COMPARATOR |
private java.util.Map<java.lang.Class,java.util.List<java.lang.Object>> |
servicesLoaded
List of services loaded, per class.
|
Constructor and Description |
---|
DefaultServiceProvider() |
Modifier and Type | Method and Description |
---|---|
(package private) static int |
compareServices(java.lang.Object o1,
java.lang.Object o2) |
int |
compareTo(javax.measure.spi.ServiceProvider o) |
int |
getPriority()
Returns a priority value of 10.
|
<Q extends javax.measure.Quantity<Q>> |
getQuantityFactory(java.lang.Class<Q> quantity)
Return a factory for this quantity
|
protected <T> T |
getService(java.lang.Class<T> serviceType) |
protected <T> java.util.List<T> |
getServices(java.lang.Class<T> serviceType)
Loads and registers services.
|
javax.measure.spi.SystemOfUnitsService |
getSystemOfUnitsService() |
javax.measure.spi.UnitFormatService |
getUnitFormatService() |
private <T> java.util.List<T> |
loadServices(java.lang.Class<T> serviceType)
Loads and registers services.
|
private final java.util.Map<java.lang.Class,java.util.List<java.lang.Object>> servicesLoaded
private static final java.util.Comparator<java.lang.Object> SERVICE_COMPARATOR
private final java.util.Map<java.lang.Class,javax.measure.spi.QuantityFactory> QUANTITY_FACTORIES
public int getPriority()
getPriority
in class javax.measure.spi.ServiceProvider
protected <T> java.util.List<T> getServices(java.lang.Class<T> serviceType)
T
- the concrete type.serviceType
- The service type.null
.protected <T> T getService(java.lang.Class<T> serviceType)
static int compareServices(java.lang.Object o1, java.lang.Object o2)
private <T> java.util.List<T> loadServices(java.lang.Class<T> serviceType)
T
- the concrete type.serviceType
- The service type.null
.public int compareTo(javax.measure.spi.ServiceProvider o)
compareTo
in interface java.lang.Comparable<javax.measure.spi.ServiceProvider>
public javax.measure.spi.SystemOfUnitsService getSystemOfUnitsService()
getSystemOfUnitsService
in class javax.measure.spi.ServiceProvider
public javax.measure.spi.UnitFormatService getUnitFormatService()
getUnitFormatService
in class javax.measure.spi.ServiceProvider
public final <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getQuantityFactory(java.lang.Class<Q> quantity)
getQuantityFactory
in class javax.measure.spi.ServiceProvider
quantity
- the quantity typeQuantityFactory
java.lang.NullPointerException