Package aQute.lib.inject
Class Injector<T extends Annotation>
java.lang.Object
aQute.lib.inject.Injector<T>
- Type Parameters:
T
- the annotation type
This class is a simple injector with a parameterized annotation. A domain
function is provided to retrieve the values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The Target class describes the target injection point. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Converter
(package private) final Function<Injector.Target<T>,
Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Collection<Field>
private Collection<Method>
getMethods
(Class<?> clazz) private Object
getValue
(Injector.Target<T> param) void
Inject an object.private Object[]
invoke
(Object target, Injector.Target<T> param, Executable method) <F> F
newInstance
(Class<F> type)
-
Field Details
-
converter
-
annotation
-
domain
-
-
Constructor Details
-
Injector
public Injector(Converter converter, Function<Injector.Target<T>, Object> domain, Class<T> annotation) Create a new Injector- Parameters:
converter
- the converter to use for conversionsdomain
- the domain function that retrieves valuesannotation
- the annotation that triggers a call to the domain
-
Injector
Create a new Injector with a default converter- Parameters:
domain
- the domain function that retrieves valuesannotation
- the annotation that triggers a call to the domain
-
-
Method Details
-
inject
Inject an object. This will inject fields and methods. Methods must have one or more arguments. The first argument is special and is always passed to the domain function as the primaryType.- Parameters:
target
- the target object to inject- Throws:
Exception
-
newInstance
- Throws:
Exception
-
getFields
-
getMethods
-
getAbove
-
getValue
- Throws:
Exception
-
invoke
private Object[] invoke(Object target, Injector.Target<T> param, Executable method) throws Exception, IllegalAccessException, InvocationTargetException
-