Package dagger.model

Class 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 or ProductionComponent
    • a partial component hierarchy rooted at a Subcomponent or ProductionSubcomponent (only when the value of -Adagger.fullBindingGraphValidation is not NONE)
    • the bindings installed by a Module or ProducerModule, including all subcomponents generated by Module#subcomponents() and ProducerModule#subcomponents()
    In the case of a BindingGraph representing a module, the root BindingGraph.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.


    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.


    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.

    • Constructor Detail

      • BindingGraph

        public BindingGraph()
    • Method Detail

      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • isModuleBindingGraph

        public boolean isModuleBindingGraph()
        use isFullBindingGraph() to tell if this is a full binding graph, or rootComponentNode().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()
        Returns true if this is a full binding graph, which contains all bindings installed in the component, or false 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

        public boolean isPartialBindingGraph()
        Returns true if the rootComponentNode() is a subcomponent. This occurs in when -Adagger.fullBindingGraphValidation is used in a compilation with a subcomponent.
      • bindings

        public<Binding> bindings()
        Returns the bindings.
      • bindings

        public<Binding> bindings​(Key key)
        Returns the bindings for a key.
      • missingBindings

        public<BindingGraph.MissingBinding> missingBindings()
        Returns the nodes that represent missing bindings.
      • componentNodes

        public<BindingGraph.ComponentNode> componentNodes()
        Returns the component nodes.
      • componentNodes

        public<BindingGraph.ComponentNode> componentNodes​(javax.lang.model.element.TypeElement component)
        Returns the component nodes for a component.
      • dependencyEdges

        public<BindingGraph.DependencyEdge> dependencyEdges()
        Returns the dependency edges.
      • entryPointEdges

        public<BindingGraph.DependencyEdge> entryPointEdges​(ComponentPath component)
        Returns the dependency edges for the entry points of a given component. Each edge's source node is that component's component node.
      • entryPointEdges

        public<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<BindingGraph.MaybeBinding> entryPointBindings()
        Returns the binding or missing binding nodes that directly satisfy entry points.
      • entryPointEdgesDependingOnBinding

        public<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<Binding> requestingBindings​(BindingGraph.MaybeBinding binding)
        Returns the bindings that directly request a given binding as a dependency.
      • requestedMaybeMissingBindings

        public<BindingGraph.MaybeBinding> requestedMaybeMissingBindings​(Binding binding)
        Returns the bindings or missing bindings that a given binding directly requests as a dependency.
        See Also: