public class CloningDependencyVisitor extends java.lang.Object implements DependencyVisitor
FilteringDependencyVisitor
, a sub graph can be created. This class creates shallow clones of the visited
dependency nodes (via DefaultDependencyNode.DefaultDependencyNode(DependencyNode)
) but clients can create a
subclass and override clone(DependencyNode)
to alter the clone process.Modifier and Type | Field and Description |
---|---|
private java.util.Map<DependencyNode,DependencyNode> |
clones |
private Stack<DependencyNode> |
parents |
private DependencyNode |
root |
Constructor and Description |
---|
CloningDependencyVisitor()
Creates a new visitor that clones the visited nodes.
|
Modifier and Type | Method and Description |
---|---|
protected DependencyNode |
clone(DependencyNode node)
Creates a clone of the specified node.
|
DependencyNode |
getRootNode()
Gets the root node of the cloned dependency graph.
|
boolean |
visitEnter(DependencyNode node)
Notifies the visitor of a node visit before its children have been processed.
|
boolean |
visitLeave(DependencyNode node)
Notifies the visitor of a node visit after its children have been processed.
|
private final java.util.Map<DependencyNode,DependencyNode> clones
private final Stack<DependencyNode> parents
private DependencyNode root
public CloningDependencyVisitor()
public final DependencyNode getRootNode()
null
.protected DependencyNode clone(DependencyNode node)
node
- The node to clone, must not be null
.null
.public final boolean visitEnter(DependencyNode node)
DependencyVisitor
visitEnter
in interface DependencyVisitor
node
- The dependency node being visited, must not be null
.true
to visit child nodes of the specified node as well, false
to skip children.public final boolean visitLeave(DependencyNode node)
DependencyVisitor
visitLeave
in interface DependencyVisitor
node
- The dependency node being visited, must not be null
.true
to visit siblings nodes of the specified node as well, false
to skip siblings.