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>Providerspecialization 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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Tget()Retrieve the first available instancedefault TgetOrNull()Retrieve the instance or null if no instance is availablebooleanhasMultiple()Determines if there is more than one available implementation for the required type and qualifiersdefault booleanisAmbiguous()Determines if there is more than one available implementation for the required type and qualifiers.default booleanisAvailable()Indicates if at least one matching provider is founddefault booleanisUnavailable()Equivalent toisUnsatisfied()booleanisUnsatisfied()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 TorElse(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 aStreaminstance
-
-
-
Method Detail
-
get
T get()
Retrieve the first available instance- Specified by:
getin interfacejavax.inject.Provider<T>- Specified by:
getin 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:
iteratorin interfacejava.lang.Iterable<T>- Returns:
- The set of available providers
-
stream
default java.util.stream.Stream<T> stream()
Adapt this set of providers to aStreaminstance- Returns:
Streamof provider instances- Since:
- 20.3.0
-
qualifier
TypeQualifier<T> qualifier()
Identifies the constraints used to select matches- Returns:
TypeQualifierinstance- Since:
- 19.3.0
-
-