public class Dependency extends Object
Key<?>
s, as well as the properties of the edge (optional/requried, lazy/eager).
Dependencies also store the context in which the dependency arose. This
is not part of the dependency's identity from the point of view of equals()
and hashCode(), which ultimately means that if the same dependency arises in
several different contexts, we will pick an arbitrary instance (specifically,
the first one encountered, see DependencyGraph
).
Modifier and Type | Field and Description |
---|---|
static Key<?> |
GINJECTOR
A unique key used to indicate that a dependency originated in the Ginjector; for instance,
keys produced by the root Ginjector, or while visiting bindings in
GuiceBindingVisitor
often have as their source GINJECTOR . |
Constructor and Description |
---|
Dependency(Key<?> source,
Key<?> target,
boolean optional,
boolean lazy,
Context context)
Construct a dependency edge from the given source to target keys.
|
Dependency(Key<?> source,
Key<?> target,
boolean optional,
boolean lazy,
String context,
Object... contextArgs)
Construct a dependency edge from the given source to target keys.
|
Dependency(Key<?> source,
Key<?> target,
Context context)
Construct a dependency edge from the given source to target keys.
|
Dependency(Key<?> source,
Key<?> target,
String context,
Object... contextArgs)
Construct a dependency edge from the given source to target keys.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Context |
getContext() |
Key<?> |
getSource() |
Key<?> |
getTarget() |
int |
hashCode() |
boolean |
isLazy() |
boolean |
isOptional() |
String |
toString() |
public static final Key<?> GINJECTOR
GuiceBindingVisitor
often have as their source GINJECTOR
.public Dependency(Key<?> source, Key<?> target, String context, Object... contextArgs)
source
- The key that depends on target. Can use GINJECTOR
as
described above.target
- the key that is depended oncontext
- a brief description of the context of the dependency (e.g., Foo.java:123)contextArgs
- arguments to pretty-print into the context as with
PrettyPrinter.format(java.lang.String, java.lang.Object...)
public Dependency(Key<?> source, Key<?> target, Context context)
source
- The key that depends on target. Can use GINJECTOR
as
described above.target
- the key that is depended oncontext
- the context of the dependency (e.g., Foo.java:123)public Dependency(Key<?> source, Key<?> target, boolean optional, boolean lazy, String context, Object... contextArgs)
source
- The key that depends on the target. Can use GINJECTOR
as
described above.target
- the key that is depended onoptional
- true
iff the dependency is optional. Errors will not be reported if
the target is unavailable.lazy
- true
iff the dependency is only needed on-demand (eg, by calling
Provider.get()
). A cycle is only a problem if none of the edges are lazy.context
- a brief description of the context of the dependency (e.g., Foo.java:123)contextArgs
- arguments to pretty-print into the context as with
PrettyPrinter.format(java.lang.String, java.lang.Object...)
public Dependency(Key<?> source, Key<?> target, boolean optional, boolean lazy, Context context)
source
- The key that depends on the target. Can use GINJECTOR
as
described above.target
- the key that is depended onoptional
- true
iff the dependency is optional. Errors will not be reported if
the target is unavailable.lazy
- true
iff the dependency is only needed on-demand (eg, by calling
Provider.get()
). A cycle is only a problem if none of the edges are lazy.context
- the context of the dependency (e.g., Foo.java:123)Copyright © 2008–2018. All rights reserved.