Class ServiceHelper

java.lang.Object
io.github.mmm.base.config.ServiceHelper

public final class ServiceHelper extends Object
Helper class for ServiceLoader.
Since:
1.0.0
  • Method Details

    • singleton

      public static final <S> S singleton(ServiceLoader<S> serviceLoader)
      Type Parameters:
      S - type of the service.
      Parameters:
      serviceLoader - the ServiceLoader that has to be provided from the module declaring the service API and holds the uses statement in its module-info.
      Returns:
      the requested service.
    • singleton

      public static final <S> S singleton(ServiceLoader<S> serviceLoader, boolean unique)
      Type Parameters:
      S - type of the service.
      Parameters:
      unique - - true if an exception is thrown if the service is not unique, false otherwise (allow overriding default).
      serviceLoader - the ServiceLoader that has to be provided from the module declaring the service API and holds the uses statement in its module-info.
      Returns:
      the requested service.
    • add

      public static final <S> void add(ServiceLoader<S> serviceLoader, Collection<S> services)
      Type Parameters:
      S - type of the service.
      Parameters:
      serviceLoader - the ServiceLoader that has to be provided from the module declaring the service API and holds the uses statement in its module-info.
      services - the Collection where to add the services from the given ServiceLoader.
    • add

      public static final <S> void add(ServiceLoader<S> serviceLoader, Collection<S> services, int min)
      Type Parameters:
      S - type of the service.
      Parameters:
      serviceLoader - the ServiceLoader that has to be provided from the module declaring the service API and holds the uses statement in its module-info.
      services - the Collection where to add the services from the given ServiceLoader.
      min - the minimum number of services required.