Class BindingGraph
- java.lang.Object
-
- dagger.model.BindingGraph
-
public abstract class BindingGraph extends java.lang.Object
A graph of bindings, dependency requests, and components.A
BindingGraph
represents one of the following:- an entire component hierarchy rooted at a
Component
orProductionComponent
- a partial component hierarchy rooted at a
Subcomponent
orProductionSubcomponent
(only when the value of-Adagger.fullBindingGraphValidation
is notNONE
) - the bindings installed by a
Module
orProducerModule
, including all subcomponents generated byModule.subcomponents()
()} andProducerModule.subcomponents()
()}
BindingGraph
representing a module, the rootBindingGraph.ComponentNode
will actually represent the module type. The graph will also be a full binding graph, which means it will contain all bindings in all modules, as well as nodes for their dependencies. Otherwise it will contain only bindings that are reachable from at least one entry point.Nodes
There is a
Binding
for each owned binding in the graph. If a binding is owned by more than one component, there is one binding object for that binding for every owning component.There is a component node (without a binding) for each component in the graph.
Edges
There is a dependency edge for each dependency request in the graph. Its target node is the binding for the binding that satisfies the request. For entry point dependency requests, the source node is the component node for the component for which it is an entry point. For other dependency requests, the source node is the binding for the binding that contains the request.
There is a subcomponent edge for each parent-child component relationship in the graph. The target node is the component node for the child component. For subcomponents defined by a subcomponent creator binding (either a method on the component or a set of
@Module.subcomponents
annotation values), the source node is the binding for the@Subcomponent.Builder
type. For subcomponents defined by subcomponent factory methods, the source node is the component node for the parent.Note that this API is experimental and will change.
- an entire component hierarchy rooted at a
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BindingGraph.ChildFactoryMethodEdge
An edge that represents a subcomponent factory method linking a parent component to a child subcomponent.static interface
BindingGraph.ComponentNode
A component node in the graph.static interface
BindingGraph.DependencyEdge
An edge that represents a dependency on a binding.static interface
BindingGraph.Edge
An edge in the binding graph.static interface
BindingGraph.MaybeBinding
A node in the binding graph that is either aBinding
or aBindingGraph.MissingBinding
.static class
BindingGraph.MissingBinding
A node in the binding graph that represents a missing binding for a key in a component.static interface
BindingGraph.Node
A node in the binding graph.static interface
BindingGraph.SubcomponentCreatorBindingEdge
-
Constructor Summary
Constructors Constructor Description BindingGraph()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.google.common.collect.ImmutableSet<Binding>
bindings()
Returns the bindings.com.google.common.collect.ImmutableSet<Binding>
bindings(Key key)
Returns the bindings for a key.java.util.Optional<BindingGraph.ComponentNode>
componentNode(ComponentPath component)
Returns the component node for a component.com.google.common.collect.ImmutableSet<BindingGraph.ComponentNode>
componentNodes()
Returns the component nodes.com.google.common.collect.ImmutableSet<BindingGraph.ComponentNode>
componentNodes(javax.lang.model.element.TypeElement component)
Returns the component nodes for a component.com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge>
dependencyEdges()
Returns the dependency edges.com.google.common.collect.ImmutableSetMultimap<DependencyRequest,BindingGraph.DependencyEdge>
dependencyEdges(Binding binding)
Returns the dependency edges for the dependencies of a binding.com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge>
dependencyEdges(DependencyRequest dependencyRequest)
Returns the dependency edges for a dependency request.com.google.common.collect.ImmutableSet<BindingGraph.MaybeBinding>
entryPointBindings()
Returns the binding or missing binding nodes that directly satisfy entry points.com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge>
entryPointEdges()
Returns the dependency edges for all entry points for all components and subcomponents.com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge>
entryPointEdges(ComponentPath component)
Returns the dependency edges for the entry points of a givencomponent
.com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge>
entryPointEdgesDependingOnBinding(BindingGraph.MaybeBinding binding)
Returns the edges for entry points that transitively depend on a binding or missing binding for a key.abstract boolean
isFullBindingGraph()
Returnstrue
if this is a full binding graph, which contains all bindings installed in the component, orfalse
if it is a reachable binding graph, which contains only bindings that are reachable from at least one entry point.boolean
isModuleBindingGraph()
Deprecated.useisFullBindingGraph()
to tell if this is a full binding graph, orrootComponentNode().isRealComponent()
to tell if the root component node is really a component or derived from a module.boolean
isPartialBindingGraph()
Deprecated.userootComponentNode().isSubcomponent()
insteadcom.google.common.collect.ImmutableSet<BindingGraph.MissingBinding>
missingBindings()
Returns the nodes that represent missing bindings.abstract com.google.common.graph.ImmutableNetwork<BindingGraph.Node,BindingGraph.Edge>
network()
Returns the graph in itsNetwork
representation.protected com.google.common.collect.ImmutableSetMultimap<java.lang.Class<? extends BindingGraph.Node>,? extends BindingGraph.Node>
nodesByClass()
com.google.common.collect.ImmutableSet<Binding>
requestedBindings(Binding binding)
Returns the bindings that a given binding directly requests as a dependency.com.google.common.collect.ImmutableSet<BindingGraph.MaybeBinding>
requestedMaybeMissingBindings(Binding binding)
Returns the bindings or missing bindings that a given binding directly requests as a dependency.com.google.common.collect.ImmutableSet<Binding>
requestingBindings(BindingGraph.MaybeBinding binding)
Returns the bindings that directly request a given binding as a dependency.BindingGraph.ComponentNode
rootComponentNode()
Returns the component node for the root component.java.lang.String
toString()
-
-
-
Method Detail
-
network
public abstract com.google.common.graph.ImmutableNetwork<BindingGraph.Node,BindingGraph.Edge> network()
Returns the graph in itsNetwork
representation.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isModuleBindingGraph
@Deprecated public boolean isModuleBindingGraph()
Deprecated.useisFullBindingGraph()
to tell if this is a full binding graph, orrootComponentNode().isRealComponent()
to tell if the root component node is really a component or derived from a module. Dagger can generate full binding graphs for components and subcomponents as well as modules.ReturnsĀtrue
if this graph was constructed from a module for full binding graph validation.
-
isFullBindingGraph
public abstract boolean isFullBindingGraph()
Returnstrue
if this is a full binding graph, which contains all bindings installed in the component, orfalse
if it is a reachable binding graph, which contains only bindings that are reachable from at least one entry point.- See Also:
- Full binding graph validation
-
isPartialBindingGraph
@Deprecated public boolean isPartialBindingGraph()
Deprecated.userootComponentNode().isSubcomponent()
insteadReturnstrue
if therootComponentNode()
is a subcomponent. This occurs in when-Adagger.fullBindingGraphValidation
is used in a compilation with a subcomponent.
-
bindings
public com.google.common.collect.ImmutableSet<Binding> bindings()
Returns the bindings.
-
bindings
public com.google.common.collect.ImmutableSet<Binding> bindings(Key key)
Returns the bindings for a key.
-
missingBindings
public com.google.common.collect.ImmutableSet<BindingGraph.MissingBinding> missingBindings()
Returns the nodes that represent missing bindings.
-
componentNodes
public com.google.common.collect.ImmutableSet<BindingGraph.ComponentNode> componentNodes()
Returns the component nodes.
-
componentNode
public java.util.Optional<BindingGraph.ComponentNode> componentNode(ComponentPath component)
Returns the component node for a component.
-
componentNodes
public com.google.common.collect.ImmutableSet<BindingGraph.ComponentNode> componentNodes(javax.lang.model.element.TypeElement component)
Returns the component nodes for a component.
-
rootComponentNode
public BindingGraph.ComponentNode rootComponentNode()
Returns the component node for the root component.
-
dependencyEdges
public com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge> dependencyEdges()
Returns the dependency edges.
-
dependencyEdges
public com.google.common.collect.ImmutableSetMultimap<DependencyRequest,BindingGraph.DependencyEdge> dependencyEdges(Binding binding)
Returns the dependency edges for the dependencies of a binding. For valid graphs, eachDependencyRequest
will map to a singleBindingGraph.DependencyEdge
. When conflicting bindings exist for a key, the multimap will have several edges for thatDependencyRequest
. Graphs that have no binding for a key will have an edge whose target node is aBindingGraph.MissingBinding
.
-
dependencyEdges
public com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge> dependencyEdges(DependencyRequest dependencyRequest)
Returns the dependency edges for a dependency request.
-
entryPointEdges
public com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge> entryPointEdges(ComponentPath component)
Returns the dependency edges for the entry points of a givencomponent
. Each edge's source node is that component's component node.
-
entryPointEdges
public com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge> entryPointEdges()
Returns the dependency edges for all entry points for all components and subcomponents. Each edge's source node is a component node.
-
entryPointBindings
public com.google.common.collect.ImmutableSet<BindingGraph.MaybeBinding> entryPointBindings()
Returns the binding or missing binding nodes that directly satisfy entry points.
-
entryPointEdgesDependingOnBinding
public com.google.common.collect.ImmutableSet<BindingGraph.DependencyEdge> entryPointEdgesDependingOnBinding(BindingGraph.MaybeBinding binding)
Returns the edges for entry points that transitively depend on a binding or missing binding for a key.
-
requestingBindings
public com.google.common.collect.ImmutableSet<Binding> requestingBindings(BindingGraph.MaybeBinding binding)
Returns the bindings that directly request a given binding as a dependency.
-
requestedBindings
public com.google.common.collect.ImmutableSet<Binding> requestedBindings(Binding binding)
Returns the bindings that a given binding directly requests as a dependency. Does not include anyBindingGraph.MissingBinding
s.- See Also:
requestedMaybeMissingBindings(Binding)
-
requestedMaybeMissingBindings
public com.google.common.collect.ImmutableSet<BindingGraph.MaybeBinding> requestedMaybeMissingBindings(Binding binding)
Returns the bindings or missing bindings that a given binding directly requests as a dependency.- See Also:
requestedBindings(Binding)
-
nodesByClass
protected com.google.common.collect.ImmutableSetMultimap<java.lang.Class<? extends BindingGraph.Node>,? extends BindingGraph.Node> nodesByClass()
-
-