T
- The type of the service that was locatedpublic interface InstanceProvider<T> extends Iterable<T>, javax.inject.Provider<T>, Supplier<T>
Provider
specialization that provides the ability to:
isUnsatisfied()
isAmbiguous()
iterator()
stream()
InstanceLocator
Modifier and Type | Method and Description |
---|---|
T |
get()
Retrieve the first available instance
|
default T |
getOrNull()
Retrieve the instance or null if no instance is available
|
boolean |
hasMultiple()
Determines if there is more than one available implementation for the required type and qualifiers
|
default boolean |
isAmbiguous()
Determines if there is more than one available implementation for the required type and qualifiers.
|
default boolean |
isAvailable()
Indicates if at least one matching provider is found
|
default boolean |
isUnavailable()
Equivalent to
isUnsatisfied() |
boolean |
isUnsatisfied()
Determines if there is no available implementation for the required type and qualifiers.
|
Iterator<T> |
iterator()
When a service has multiple providers (which can be determined by calling
isAmbiguous() ) this iterator enumerates each
of the available providers |
default T |
orElse(T value)
Retrieve the instance or the specified default value if no instance is available
|
TypeQualifier<T> |
qualifier()
Identifies the constraints used to select matches
|
default Stream<T> |
stream()
Adapt this set of providers to a
Stream instance |
forEach, spliterator
T get()
get
in interface javax.inject.Provider<T>
get
in interface Supplier<T>
TypeDependencyNotAvailableException
- if no instance is availabledefault T orElse(T value)
value
- The default value to provide if no instance is availabledefault T getOrNull()
boolean hasMultiple()
default boolean isAmbiguous()
hasMultiple()
default boolean isAvailable()
default boolean isUnavailable()
isUnsatisfied()
boolean isUnsatisfied()
get()
will raise a RuntimeException
Iterator<T> iterator()
isAmbiguous()
) this iterator enumerates each
of the available providersdefault Stream<T> stream()
Stream
instanceStream
of provider instancesTypeQualifier<T> qualifier()
TypeQualifier
instance