Package oracle.dbtools.plugin.api.di
Interface InstanceProvider<T>
- Type Parameters:
T- The type of the service that was located
- All Known Implementing Classes:
DeferredInstanceProvider,ResolvedInstances
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:
-
Method Summary
Modifier and TypeMethodDescriptionget()Retrieve the first available instancedefault TRetrieve the instance or null if no instance is availablebooleanDetermines if there is more than one available implementation for the required type and qualifiersdefault booleanDetermines if there is more than one available implementation for the required type and qualifiers.default booleanIndicates if at least one matching provider is founddefault booleanEquivalent toisUnsatisfied()booleanDetermines if there is no available implementation for the required type and qualifiers.iterator()When a service has multiple providers (which can be determined by callingisAmbiguous()) this iterator enumerates each of the available providersdefault TRetrieve the instance or the specified default value if no instance is availableIdentifies the constraints used to select matchesstream()Adapt this set of providers to aStreaminstanceMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
get
T get()Retrieve the first available instance- Specified by:
getin interfacejakarta.inject.Provider<T>- Specified by:
getin interfaceSupplier<T>- Returns:
- the first available instance
- Throws:
TypeDependencyNotAvailableException- if no instance is available
-
orElse
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
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
-
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
When a service has multiple providers (which can be determined by callingisAmbiguous()) this iterator enumerates each of the available providers -
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
-