Class DefaultServiceProvider

java.lang.Object
javax.measure.spi.ServiceProvider
tech.units.indriya.spi.DefaultServiceProvider
All Implemented Interfaces:
Comparable<javax.measure.spi.ServiceProvider>

public class DefaultServiceProvider extends javax.measure.spi.ServiceProvider implements Comparable<javax.measure.spi.ServiceProvider>
This class extends the ServiceProvider class and hereby uses the JDK ServiceLoader to load the required services.
Since:
1.0
Version:
1.0
  • Field Details

    • servicesLoaded

      private final Map<Class,List<Object>> servicesLoaded
      List of services loaded, per class.
    • SERVICE_COMPARATOR

      private static final Comparator<Object> SERVICE_COMPARATOR
    • QUANTITY_FACTORIES

      private final Map<Class,javax.measure.spi.QuantityFactory> QUANTITY_FACTORIES
  • Constructor Details

    • DefaultServiceProvider

      public DefaultServiceProvider()
  • Method Details

    • getPriority

      public int getPriority()
      Returns a priority value of 10.
      Overrides:
      getPriority in class javax.measure.spi.ServiceProvider
      Returns:
      10, overriding the default provider.
    • getServices

      protected <T> List<T> getServices(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(Class<T> serviceType)
    • compareServices

      static int compareServices(Object o1, Object o2)
    • loadServices

      private <T> List<T> loadServices(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 interface Comparable<javax.measure.spi.ServiceProvider>
    • getSystemOfUnitsService

      public javax.measure.spi.SystemOfUnitsService getSystemOfUnitsService()
      Specified by:
      getSystemOfUnitsService in class javax.measure.spi.ServiceProvider
    • getUnitFormatService

      public javax.measure.spi.UnitFormatService getUnitFormatService()
      Specified by:
      getUnitFormatService in class javax.measure.spi.ServiceProvider
    • getQuantityFactory

      public final <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getQuantityFactory(Class<Q> quantity)
      Return a factory for this quantity
      Specified by:
      getQuantityFactory in class javax.measure.spi.ServiceProvider
      Parameters:
      quantity - the quantity type
      Returns:
      the QuantityFactory
      Throws:
      NullPointerException