Package org.int4.dirk.library
Class ProviderInjectionTargetExtension<P,E>
- java.lang.Object
-
- org.int4.dirk.library.ProviderInjectionTargetExtension<P,E>
-
- Type Parameters:
P- the type of the providerE- the type the provider provides
- All Implemented Interfaces:
InjectionTargetExtension<P,E>
public class ProviderInjectionTargetExtension<P,E> extends java.lang.Object implements InjectionTargetExtension<P,E>
Configurable providerInjectionTargetExtensionwhich allows selecting the type of provider it should handle.
-
-
Constructor Summary
Constructors Constructor Description ProviderInjectionTargetExtension(java.lang.Class<P> providerClass, java.util.function.Function<java.util.function.Supplier<E>,P> providerFactory)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.reflect.TypegetElementType(java.lang.reflect.Type type)Returns the element type of the given type by unwrapping the given type.PgetInstance(InstantiationContext<E> context)Creates an instance of typeTusing the givenInstantiationContext.java.lang.Class<?>getTargetClass()Returns the target class extended by this extension.java.util.Set<TypeTrait>getTypeTraits()Returns theTypeTraits of this extension.
-
-
-
Constructor Detail
-
ProviderInjectionTargetExtension
public ProviderInjectionTargetExtension(java.lang.Class<P> providerClass, java.util.function.Function<java.util.function.Supplier<E>,P> providerFactory)
Constructs a new instance.- Parameters:
providerClass- aClassrepresenting the provider type, cannot benullproviderFactory- a function to create the provider instance given a supplier, cannot benull
-
-
Method Detail
-
getTargetClass
public java.lang.Class<?> getTargetClass()
Description copied from interface:InjectionTargetExtensionReturns the target class extended by this extension.- Specified by:
getTargetClassin interfaceInjectionTargetExtension<P,E>- Returns:
- a
Class, nevernull
-
getElementType
public java.lang.reflect.Type getElementType(java.lang.reflect.Type type)
Description copied from interface:InjectionTargetExtensionReturns the element type of the given type by unwrapping the given type. Returningnullor the same type is not allowed.- Specified by:
getElementTypein interfaceInjectionTargetExtension<P,E>- Parameters:
type- aTypeto unwrap, cannot benull- Returns:
- the element type of the given type by unwrapping the given type, never
null
-
getTypeTraits
public java.util.Set<TypeTrait> getTypeTraits()
Description copied from interface:InjectionTargetExtensionReturns theTypeTraits of this extension.- Specified by:
getTypeTraitsin interfaceInjectionTargetExtension<P,E>- Returns:
- a set of
TypeTrait, nevernullor containsnull, but can be empty
-
getInstance
public P getInstance(InstantiationContext<E> context)
Description copied from interface:InjectionTargetExtensionCreates an instance of typeTusing the givenInstantiationContext. Returningnullis allowed to indicate the absence of a value. Depending on the destination where the value is used this can meannullis injected (methods and constructors), that the value is not injected (fields) or that anUnsatisfiedResolutionExceptionis thrown (direct instance resolver call).- Specified by:
getInstancein interfaceInjectionTargetExtension<P,E>- Parameters:
context- anInstantiationContext, cannot benull- Returns:
- an instance of type
T, can benull
-
-