Package oracle.dbtools.plugin.api.di
Class DeferredInstanceProvider<T>
- java.lang.Object
-
- oracle.dbtools.plugin.api.di.DeferredInstanceProvider<T>
-
- Type Parameters:
T
- The type of instance to provide
- All Implemented Interfaces:
jakarta.inject.Provider<T>
,java.lang.Iterable<T>
,java.util.function.Supplier<T>
,InstanceProvider<T>
public class DeferredInstanceProvider<T> extends java.lang.Object implements InstanceProvider<T>
InstanceProvider
implementation that defers resolving an instance untilget()
,hasMultiple()
,isUnsatisfied()
, oriterator()
is invoked- Since:
- 19.3.0
- Author:
- cdivilly
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> DeferredInstanceProvider<T>
from(TypeQualifier<T> service, InstanceLocator locator)
Instantiate aDeferredInstanceProvider
T
get()
Retrieve the first available instanceboolean
hasMultiple()
Determines if there is more than one available implementation for the required type and qualifiersboolean
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 callingInstanceProvider.isAmbiguous()
) this iterator enumerates each of the available providersTypeQualifier<T>
qualifier()
Identifies the constraints used to select matchesjava.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface oracle.dbtools.plugin.api.di.InstanceProvider
getOrNull, isAmbiguous, isAvailable, isUnavailable, orElse, stream
-
-
-
-
Method Detail
-
get
public T get()
Description copied from interface:InstanceProvider
Retrieve the first available instance- Specified by:
get
in interfaceInstanceProvider<T>
- Specified by:
get
in interfacejakarta.inject.Provider<T>
- Specified by:
get
in interfacejava.util.function.Supplier<T>
- Returns:
- the first available instance
-
hasMultiple
public boolean hasMultiple()
Description copied from interface:InstanceProvider
Determines if there is more than one available implementation for the required type and qualifiers- Specified by:
hasMultiple
in interfaceInstanceProvider<T>
- Returns:
- true if there are multiple providers, false otherwise
-
isUnsatisfied
public boolean isUnsatisfied()
Description copied from interface:InstanceProvider
Determines if there is no available implementation for the required type and qualifiers. If this method returns true, then callingInstanceProvider.get()
will raise aRuntimeException
- Specified by:
isUnsatisfied
in interfaceInstanceProvider<T>
- Returns:
- true if there is no provider, false otherwise
-
iterator
public java.util.Iterator<T> iterator()
Description copied from interface:InstanceProvider
When a service has multiple providers (which can be determined by callingInstanceProvider.isAmbiguous()
) this iterator enumerates each of the available providers- Specified by:
iterator
in interfaceInstanceProvider<T>
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- The set of available providers
-
qualifier
public TypeQualifier<T> qualifier()
Description copied from interface:InstanceProvider
Identifies the constraints used to select matches- Specified by:
qualifier
in interfaceInstanceProvider<T>
- Returns:
TypeQualifier
instance
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
from
public static <T> DeferredInstanceProvider<T> from(TypeQualifier<T> service, InstanceLocator locator)
Instantiate aDeferredInstanceProvider
- Type Parameters:
T
- The type of instance to provide- Parameters:
service
- The service that needs to be providedlocator
- The locator that can provide the service.- Returns:
DeferredInstanceProvider
-
-