Package org.int4.dirk.core.definition
Class GenericBindingProvider<B>
- java.lang.Object
-
- org.int4.dirk.core.definition.GenericBindingProvider<B>
-
- Type Parameters:
B- the type of the resulting binding
public class GenericBindingProvider<B> extends java.lang.ObjectProvides bindings for constructors, methods and fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGenericBindingProvider.BindingFactory<B>Factory for creating bindings that have been found.
-
Constructor Summary
Constructors Constructor Description GenericBindingProvider(AnnotationStrategy annotationStrategy, GenericBindingProvider.BindingFactory<B> factory)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.reflect.Constructor<?>getAnnotatedConstructor(java.lang.Class<?> cls)Returns an annotatedConstructorsuitable for injection.<T> java.lang.reflect.Constructor<T>getConstructor(java.lang.Class<T> cls)Returns aConstructorsuitable for injection.java.util.List<B>ofConstructor(java.lang.reflect.Constructor<?> constructor)Returns all bindings for the givenConstructor.java.util.List<B>ofConstructorAndMembers(java.lang.reflect.Constructor<?> constructor, java.lang.Class<?> cls)Returns all bindings for the givenConstructorand all member bindings for the given class.java.util.List<B>ofField(java.lang.reflect.Field field, java.lang.reflect.Type ownerType)Returns all bindings for the givenField.java.util.List<B>ofMembers(java.lang.Class<?> cls)Returns all member bindings for the given class.java.util.List<B>ofMethod(java.lang.reflect.Method method, java.lang.reflect.Type ownerType)Returns all bindings for the givenMethod.
-
-
-
Constructor Detail
-
GenericBindingProvider
public GenericBindingProvider(AnnotationStrategy annotationStrategy, GenericBindingProvider.BindingFactory<B> factory)
Constructs a new instance.- Parameters:
annotationStrategy- anAnnotationStrategy, cannot benullfactory- a factory for bindings of typeB, cannot benull
-
-
Method Detail
-
ofConstructorAndMembers
public java.util.List<B> ofConstructorAndMembers(java.lang.reflect.Constructor<?> constructor, java.lang.Class<?> cls) throws org.int4.dirk.api.definition.DefinitionException
Returns all bindings for the givenConstructorand all member bindings for the given class.- Parameters:
constructor- aConstructorto examine for bindings, cannot benullcls- aClassto examine for bindings, cannot benull- Returns:
- a list of bindings, never
nulland never containsnulls, but can be empty - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
ofConstructor
public java.util.List<B> ofConstructor(java.lang.reflect.Constructor<?> constructor) throws org.int4.dirk.api.definition.DefinitionException
Returns all bindings for the givenConstructor.- Parameters:
constructor- aConstructorto examine for bindings, cannot benull- Returns:
- a list of bindings, never
nulland never containsnulls, but can be empty - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
ofMembers
public java.util.List<B> ofMembers(java.lang.Class<?> cls) throws org.int4.dirk.api.definition.DefinitionException
Returns all member bindings for the given class. These are inject annotated methods and fields, but not constructors.- Parameters:
cls- aClassto examine for bindings, cannot benull- Returns:
- a list of bindings, never
nulland never containsnull, but can be empty - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
ofMethod
public java.util.List<B> ofMethod(java.lang.reflect.Method method, java.lang.reflect.Type ownerType) throws org.int4.dirk.api.definition.DefinitionException
Returns all bindings for the givenMethod.- Parameters:
method- aMethodto examine for bindings, cannot benullownerType- aTypein which this method is declared, cannot benull- Returns:
- a list of bindings, never
nulland never containsnulls, but can be empty - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
ofField
public java.util.List<B> ofField(java.lang.reflect.Field field, java.lang.reflect.Type ownerType) throws org.int4.dirk.api.definition.DefinitionException
Returns all bindings for the givenField.- Parameters:
field- aFieldto examine for bindings, cannot benullownerType- aTypein which this executable is declared, cannot benull- Returns:
- an immutable list of bindings, never
nulland never containsnulls, but can be empty - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
getAnnotatedConstructor
public java.lang.reflect.Constructor<?> getAnnotatedConstructor(java.lang.Class<?> cls) throws org.int4.dirk.api.definition.DefinitionExceptionReturns an annotatedConstructorsuitable for injection.- Parameters:
cls- aClass, cannot benull- Returns:
- a
Constructorsuitable for injection, nevernull - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
getConstructor
public <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> cls) throws org.int4.dirk.api.definition.DefinitionExceptionReturns aConstructorsuitable for injection. A public empty constructor is considered suitable if no other constructors are annotated.- Type Parameters:
T- the class type- Parameters:
cls- aClass, cannot benull- Returns:
- a
Constructorsuitable for injection, nevernull - Throws:
org.int4.dirk.api.definition.DefinitionException- when a definition problem is encountered
-
-