Class FallbackOptionalService<T>

java.lang.Object
net.solarnetwork.service.FallbackOptionalService<T>
Type Parameters:
T - the service type
All Implemented Interfaces:
OptionalService<T>

public class FallbackOptionalService<T> extends Object implements OptionalService<T>
Implementation of OptionalService using a collection of delegate optional services, returning the first available service when asked.

This can be useful when the an optional service should be used in preference to a completely independently configured default service.

Since:
1.59
Version:
1.0
Author:
matt
  • Constructor Details

    • FallbackOptionalService

      public FallbackOptionalService(Collection<OptionalService<T>> services)
      Constructor.
      Parameters:
      services - the services to use
  • Method Details

    • service

      public T service()
      Description copied from interface: OptionalService
      Get the configured service, or null if none available.
      Specified by:
      service in interface OptionalService<T>
      Returns:
      the service, or null