Package dagger.android
Class DispatchingAndroidInjector<T>
- java.lang.Object
-
- dagger.android.DispatchingAndroidInjector<T>
-
- Type Parameters:
T
- the core Android type to be injected
- All Implemented Interfaces:
AndroidInjector<T>
@Beta public final class DispatchingAndroidInjector<T> extends java.lang.Object implements AndroidInjector<T>
Performs members-injection on instances of core Android types (e.g.Activity
,Fragment
) that are constructed by the Android framework and not by Dagger. This class relies on an injected mapping from each concrete class to anAndroidInjector.Factory
for anAndroidInjector
of that class. Each concrete class must have its own entry in the map, even if it extends another class which is already present in the map. CallsObject.getClass()
on the instance in order to find the appropriateAndroidInjector.Factory
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DispatchingAndroidInjector.InvalidInjectorBindingException
Exception thrown if an incorrect binding is made for aAndroidInjector.Factory
.-
Nested classes/interfaces inherited from interface dagger.android.AndroidInjector
AndroidInjector.Builder<T>, AndroidInjector.Factory<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
inject(T instance)
Performs members-injection oninstance
.boolean
maybeInject(T instance)
Attempts to perform members-injection oninstance
, returningtrue
if successful,false
otherwise.
-
-
-
Method Detail
-
maybeInject
@CanIgnoreReturnValue public boolean maybeInject(T instance)
Attempts to perform members-injection oninstance
, returningtrue
if successful,false
otherwise.- Throws:
DispatchingAndroidInjector.InvalidInjectorBindingException
- if the injector factory bound for a class does not inject instances of that class
-
inject
public void inject(T instance)
Performs members-injection oninstance
.- Specified by:
inject
in interfaceAndroidInjector<T>
- Throws:
DispatchingAndroidInjector.InvalidInjectorBindingException
- if the injector factory bound for a class does not inject instances of that classjava.lang.IllegalArgumentException
- if noAndroidInjector.Factory
is bound forinstance
-
-