public class ComponentTreeTraverser extends Object
Subclasses can override visitComponent(BindingGraph) to perform custom logic at each
component in the tree, and visitSubcomponentFactoryMethod(BindingGraph, BindingGraph,
ExecutableElement) to perform custom logic at each subcomponent factory method.
Subclasses can override bindingGraphTraverser(ComponentTreePath, DependencyRequest)
to traverse each entry point within each component in the tree.
| Modifier and Type | Class and Description |
|---|---|
static class |
ComponentTreeTraverser.BindingGraphTraverser
An object that traverses the binding graph starting from an entry point.
|
static class |
ComponentTreeTraverser.ComponentTreePath
A path from the root component to a component within the component tree during a traversal.
|
static class |
ComponentTreeTraverser.DependencyTrace
An immutable snapshot of a path through the binding graph.
|
| Constructor and Description |
|---|
ComponentTreeTraverser(dagger.internal.codegen.BindingGraph rootGraph)
Constructs a traverser for a root (component, not subcomponent) binding graph.
|
| Modifier and Type | Method and Description |
|---|---|
protected ComponentTreeTraverser.BindingGraphTraverser |
bindingGraphTraverser(ComponentTreeTraverser.ComponentTreePath componentPath,
dagger.internal.codegen.DependencyRequest entryPoint)
Returns an object that traverses the binding graph starting from an entry point.
|
protected ComponentTreeTraverser.ComponentTreePath |
componentTreePath()
Returns an immutable snapshot of the path from the root component to the currently visited
component.
|
void |
traverseComponents()
Calls
visitComponent(BindingGraph) for the root component. |
protected void |
visitComponent(dagger.internal.codegen.BindingGraph graph)
Called once for each component in a component hierarchy.
|
protected void |
visitEntryPoint(dagger.internal.codegen.DependencyRequest entryPoint,
dagger.internal.codegen.BindingGraph graph)
Called once for each entry point in a component.
|
protected void |
visitSubcomponentFactoryMethod(dagger.internal.codegen.BindingGraph graph,
dagger.internal.codegen.BindingGraph parent,
ExecutableElement factoryMethod)
Called if this component was installed in its parent by a subcomponent factory method.
|
public ComponentTreeTraverser(dagger.internal.codegen.BindingGraph rootGraph)
public final void traverseComponents()
visitComponent(BindingGraph) for the root component.IllegalStateException - if a traversal is in progressprotected void visitComponent(dagger.internal.codegen.BindingGraph graph)
Subclasses can override this method to perform whatever logic is required per component.
They should call the super implementation if they want to continue the traversal in the
standard order.
This implementation does the following:
visitSubcomponentFactoryMethod(BindingGraph, BindingGraph, ExecutableElement).
visitEntryPoint(DependencyRequest,
BindingGraph).
visitComponent(BindingGraph), updating the
traversal state.
graph - the currently visited graphprotected void visitSubcomponentFactoryMethod(dagger.internal.codegen.BindingGraph graph,
dagger.internal.codegen.BindingGraph parent,
ExecutableElement factoryMethod)
This implementation does nothing.
graph - the currently visited graphparent - the parent graphfactoryMethod - the factory method in the parent component that declares that the current
component is a childprotected void visitEntryPoint(dagger.internal.codegen.DependencyRequest entryPoint,
dagger.internal.codegen.BindingGraph graph)
Subclasses can override this method to perform whatever logic is required per entry point.
They should call the super implementation if they want to continue the traversal in the
standard order.
This implementation passes the entry point and the current component tree path to bindingGraphTraverser(ComponentTreePath, DependencyRequest), and calls ComponentTreeTraverser.BindingGraphTraverser.traverseDependencies() on the returned object.
graph - the graph for the component that contains the entry pointprotected ComponentTreeTraverser.BindingGraphTraverser bindingGraphTraverser(ComponentTreeTraverser.ComponentTreePath componentPath, dagger.internal.codegen.DependencyRequest entryPoint)
This implementation returns a no-op object that does nothing. Subclasses should override in order to perform custom logic within the binding graph.
componentPath - the path from the root component to the component that includes the entry
pointentryPoint - the entry pointprotected final ComponentTreeTraverser.ComponentTreePath componentTreePath()
Copyright © 2012–2017 The Dagger Authors. All rights reserved.