Package oracle.dbtools.plugin.api.di
Interface InstanceProvider<T>
-
- Type Parameters:
T
- The type of the service that was located
- All Superinterfaces:
java.lang.Iterable<T>
,javax.inject.Provider<T>
,java.util.function.Supplier<T>
- All Known Implementing Classes:
DeferredInstanceProvider
,ResolvedInstances
public interface InstanceProvider<T> extends java.lang.Iterable<T>, javax.inject.Provider<T>, java.util.function.Supplier<T>
Provider
specialization that provides the ability to:- determine if a provider implementation was found, via
isUnsatisfied()
- determine if there are multiple implementations found, via
isAmbiguous()
- Iterate over the available implementations, via
iterator()
- Stream through available implementations, via
stream()
- Author:
- cdivilly
- See Also:
InstanceLocator
-
<section role="region">
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description T
get()
Retrieve the first available instancedefault T
getOrNull()
Retrieve the instance or null if no instance is availableboolean
hasMultiple()
Determines if there is more than one available implementation for the required type and qualifiersdefault 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 founddefault boolean
isUnavailable()
Equivalent toisUnsatisfied()
boolean
isUnsatisfied()
Determines if there is no available implementation for the required type and qualifiers.java.util.Iterator<T>
iterator()
When a service has multiple providers (which can be determined by callingisAmbiguous()
) this iterator enumerates each of the available providersdefault T
orElse(T value)
Retrieve the instance or the specified default value if no instance is availableTypeQualifier<T>
qualifier()
Identifies the constraints used to select matchesdefault java.util.stream.Stream<T>
stream()
Adapt this set of providers to aStream
instance
-
-
<section role="region">
-
Method Detail
-
get
T get()
Retrieve the first available instance- Specified by:
get
in interfacejavax.inject.Provider<T>
- Specified by:
get
in interfacejava.util.function.Supplier<T>
- Returns:
- the first available instance
- Throws:
TypeDependencyNotAvailableException
- if no instance is available
-
orElse
default T orElse(T value)
Retrieve the instance or the specified default value if no instance is available- Parameters:
value
- The default value to provide if no instance is available- Returns:
- The first available instance or the provided default value
-
getOrNull
default T getOrNull()
Retrieve the instance or null if no instance is available- Returns:
- The first available instance or null if no instance is available
-
hasMultiple
boolean hasMultiple()
Determines if there is more than one available implementation for the required type and qualifiers- Returns:
- true if there are multiple providers, false otherwise
- Since:
- 19.3.0
-
isAmbiguous
default boolean isAmbiguous()
Determines if there is more than one available implementation for the required type and qualifiers. Synonym forhasMultiple()
- Returns:
- true if there are multiple providers, false otherwise
-
isAvailable
default boolean isAvailable()
Indicates if at least one matching provider is found- Returns:
- true if one or more providers is available, false otherwise
- Since:
- 19.3.0
-
isUnavailable
default boolean isUnavailable()
Equivalent toisUnsatisfied()
- Returns:
- true if no matching provider is available, false otherwise
- Since:
- 19.3.0
-
isUnsatisfied
boolean isUnsatisfied()
Determines if there is no available implementation for the required type and qualifiers. If this method returns true, then callingget()
will raise aRuntimeException
- Returns:
- true if there is no provider, false otherwise
-
iterator
java.util.Iterator<T> iterator()
When a service has multiple providers (which can be determined by callingisAmbiguous()
) this iterator enumerates each of the available providers- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- The set of available providers
-
stream
default java.util.stream.Stream<T> stream()
Adapt this set of providers to aStream
instance- Returns:
Stream
of provider instances- Since:
- 20.3.0
-
qualifier
TypeQualifier<T> qualifier()
Identifies the constraints used to select matches- Returns:
TypeQualifier
instance- Since:
- 19.3.0
-
-