Modifier and Type | Optional Element and Description |
---|---|
Class<?> |
addsTo
An optional
@Module -annotated class upon which this module can be
added to form a complete graph. |
boolean |
complete
True if all of the bindings required by this module can also be satisfied
by this module, its
includes() and its addsTo() . |
Class<?>[] |
includes
Additional
@Module -annotated classes from which this module is
composed. |
Class<?>[] |
injects
Returns classes that object graphs created with this module must be able to
inject.
|
boolean |
library
False if all the included bindings in this module are necessary to satisfy
all of its
injectable types . |
boolean |
overrides
True if
@Provides methods from this module are permitted to
override those of other modules. |
Class<?>[] |
staticInjections |
public abstract Class<?>[] injects
ObjectGraph.get(java.lang.Class<T>)
and
the types of instances passed ObjectGraph.inject(T)
.
It is an error to call ObjectGraph.get(java.lang.Class<T>)
or ObjectGraph.inject(T)
with a type that isn't listed in the injects
set for any of the object graph's modules. Making such a call will trigger
an IllegalArgumentException
at runtime.
Maintaining this set is onerous, but doing so provides benefits to the application. This set enables dagger to perform more aggressive static analysis than would be otherwise possible:
complete=false
to
disable this check for the current module.
library=true
to disable this check for the current module.
public abstract Class<?>[] staticInjections
public abstract boolean overrides
@Provides
methods from this module are permitted to
override those of other modules. This is a dangerous feature as it permits
binding conflicts to go unnoticed. It should only be used in test and
development modules.public abstract Class<?>[] includes
@Module
-annotated classes from which this module is
composed. The de-duplicated contributions of the modules in
includes
, and of their inclusions recursively, are all contributed
to the object graph.public abstract Class<?> addsTo
@Module
-annotated class upon which this module can be
added
to form a complete graph.public abstract boolean complete
includes()
and its addsTo()
. If a module
is complete it is eligible for additional static checking: tools can detect
if required bindings are not available. Modules that have external
dependencies must use complete = false
.public abstract boolean library
injectable types
. If a module is not a library
module, it is eligible for additional static checking: tools can detect if
included bindings are not necessary. If you provide bindings that are not
used by this module's graph, then you must declare library = true
.
This is intended to help you detect dead code.
Copyright © 2014 Square, Inc.. All Rights Reserved.