Package net.solarnetwork.service
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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA convenient configurable optional service collection. -
Method Summary
Modifier and TypeMethodDescriptionservices()Get the collection of configured services.static <T> Iterable<T>services(OptionalServiceCollection<T> optional) Resolve an optional service.static <T> Iterable<T>services(OptionalServiceCollection<T> optional, Iterable<T> fallback) Resolve an optional service with a fallback.
-
Method Details
-
services
Get the collection of configured services.- Returns:
- the services, never null but could be empty
-
services
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
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 nullfallback- the result to return ifoptionalis null or its resolved service collection is null- Returns:
- the resolved services, or
fallback - Since:
- 1.1
-