Interface OptionalServiceCollection<T>

Type Parameters:
T - the tracked service type
All Known Subinterfaces:
OptionalServiceCollection.OptionalFilterableServiceCollection<T>
All Known Implementing Classes:
StaticOptionalServiceCollection

public interface OptionalServiceCollection<T>
API for a collection of "optional" services. This API is like a simplified OSGi ServiceTracker for a collection of services. Calling the services() method will return the all available matching services.
Version:
1.1
Author:
matt
See Also:
  • Method Details

    • services

      Iterable<T> services()
      Get the collection of configured services.
      Returns:
      the services, never null but could be empty
    • services

      static <T> Iterable<T> services(OptionalServiceCollection<T> optional)
      Resolve an optional service.

      This method is a convenient way to deal with a possibly null OptionalServiceCollection.

      Type Parameters:
      T - the service type
      Parameters:
      optional - the optional service collection, or null
      Returns:
      the resolved services, or null
      Since:
      1.1
    • services

      static <T> Iterable<T> services(OptionalServiceCollection<T> optional, Iterable<T> fallback)
      Resolve an optional service with a fallback.

      This method is a convenient way to deal with a possibly null OptionalServiceCollection.

      Type Parameters:
      T - the service type
      Parameters:
      optional - the optional service collection, or null
      fallback - the result to return if optional is null or its resolved service collection is null
      Returns:
      the resolved services, or fallback
      Since:
      1.1