Class Injector
java.lang.Object
io.github.cjstehno.testthings.inject.Injector
The entry point for the injection framework, providing a simple configurable means of injecting values into an
instance via reflection.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
inject
(T instance) Injects the configured injections into the provided object instance.static <T> T
inject
(T instance, Consumer<Injections> config) Applies the configured injections on the object instance.static Injector
injector
(Injections injections) Creates a new Injector with the provided injections configured.static Injector
injector
(Consumer<Injections> config) Creates an injector with the provided configured injections.
-
Constructor Details
-
Injector
public Injector()
-
-
Method Details
-
injector
Creates an injector with the provided configured injections.- Parameters:
config
- the configured injections- Returns:
- the configured injector
-
injector
Creates a new Injector with the provided injections configured.- Parameters:
injections
- the injections- Returns:
- the injector
-
inject
public static <T> T inject(T instance, Consumer<Injections> config) throws ReflectiveOperationException Applies the configured injections on the object instance.- Type Parameters:
T
- the type of target instance- Parameters:
instance
- the object instanceconfig
- the configured injections- Returns:
- the instance of the object populated with the injected values
- Throws:
ReflectiveOperationException
- if there is a problem with the reflection operations
-
inject
Injects the configured injections into the provided object instance.- Type Parameters:
T
- the type of the target instance- Parameters:
instance
- the object instance- Returns:
- the instance of the object populated with the injected values
- Throws:
ReflectiveOperationException
- if there is a problem with the reflection operations
-