Package tech.units.indriya.spi
Class DefaultServiceProvider
- java.lang.Object
-
- javax.measure.spi.ServiceProvider
-
- tech.units.indriya.spi.DefaultServiceProvider
-
- All Implemented Interfaces:
java.lang.Comparable<javax.measure.spi.ServiceProvider>
public class DefaultServiceProvider extends javax.measure.spi.ServiceProvider implements java.lang.Comparable<javax.measure.spi.ServiceProvider>
This class extends theServiceProvider
class and hereby uses the JDKServiceLoader
to load the required services.- Since:
- 1.0
- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description DefaultServiceProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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>>
javax.measure.spi.QuantityFactory<Q>getQuantityFactory(java.lang.Class<Q> quantity)
Return a factory for this quantityprotected <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.
-
-
-
Field Detail
-
servicesLoaded
private final java.util.Map<java.lang.Class,java.util.List<java.lang.Object>> servicesLoaded
List of services loaded, per class.
-
SERVICE_COMPARATOR
private static final java.util.Comparator<java.lang.Object> SERVICE_COMPARATOR
-
QUANTITY_FACTORIES
private final java.util.Map<java.lang.Class,javax.measure.spi.QuantityFactory> QUANTITY_FACTORIES
-
-
Method Detail
-
getPriority
public int getPriority()
Returns a priority value of 10.- Overrides:
getPriority
in classjavax.measure.spi.ServiceProvider
- Returns:
- 10, overriding the default provider.
-
getServices
protected <T> java.util.List<T> getServices(java.lang.Class<T> serviceType)
Loads and registers services.- Type Parameters:
T
- the concrete type.- Parameters:
serviceType
- The service type.- Returns:
- the items found, never
null
.
-
getService
protected <T> T getService(java.lang.Class<T> serviceType)
-
compareServices
static int compareServices(java.lang.Object o1, java.lang.Object o2)
-
loadServices
private <T> java.util.List<T> loadServices(java.lang.Class<T> serviceType)
Loads and registers services.- Type Parameters:
T
- the concrete type.- Parameters:
serviceType
- The service type.- Returns:
- the items found, never
null
.
-
compareTo
public int compareTo(javax.measure.spi.ServiceProvider o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<javax.measure.spi.ServiceProvider>
-
getSystemOfUnitsService
public javax.measure.spi.SystemOfUnitsService getSystemOfUnitsService()
- Specified by:
getSystemOfUnitsService
in classjavax.measure.spi.ServiceProvider
-
getUnitFormatService
public javax.measure.spi.UnitFormatService getUnitFormatService()
- Specified by:
getUnitFormatService
in classjavax.measure.spi.ServiceProvider
-
getQuantityFactory
public final <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getQuantityFactory(java.lang.Class<Q> quantity)
Return a factory for this quantity- Specified by:
getQuantityFactory
in classjavax.measure.spi.ServiceProvider
- Parameters:
quantity
- the quantity type- Returns:
- the
QuantityFactory
- Throws:
java.lang.NullPointerException
-
-