T
- the type to inject for@ThreadSafe public final class Injector<T> extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Injector<T> |
inject(Class<T> clazz)
Binds a class
|
static void |
injectAll(Object instance)
Injects all fields of an existing object
|
static <T> T |
newObject(Class<T> clazz,
Object... args)
Creates a new object which has injectable fields, using the injectable constructor
|
static void |
staticInject(Class<?> clazz)
Injects all static fields in the class
|
void |
with(Producer<T> producer)
Binds the provided class to the producer
|
void |
with(T instance)
Binds the provided class to the instance given
|
public static <T> Injector<T> inject(Class<T> clazz)
This returns an injector which you MUST use to bind the producer
T
- the type of the classclazz
- the class to bindpublic void with(Producer<T> producer)
The producer creates objects for injectable fields with that particular type
producer
- the producing classpublic void with(T instance)
This provides singleton-like functionality for the injector
instance
- the instance to return for any injectionpublic static void staticInject(Class<?> clazz)
This does not inject any constructors, only static fields of the provided class to inject
clazz
- the class with static fields to injectpublic static <T> T newObject(Class<T> clazz, Object... args)
T
- the type to returnclazz
- the class to instantiateargs
- the parameters, not including the injectable classes, in order of declarationCopyright © 2016. All rights reserved.