public void visit(Graph graph, Node node, NodeData nd) { Iterator<Node> iter = node.getChildren().iterator(); // Iterator<Node> while (iter.hasNext()) { Node child = iter.next(); // Make sure the child is in the graph so it can be visited later if necessary. graph.add(child); // Mark the child as a non-root, since a child is never a root. NodeData cnd = graph.getNodeData(child); cnd.notRoot(); } } });
public void visit(Graph graph, Node node, NodeData nd) { Iterator<Node> iter = node.getChildren().iterator(); // Iterator<Node> while (iter.hasNext()) { Node child = iter.next(); // Make sure the child is in the graph so it can be visited later if necessary. graph.add(child); // Mark the child as a non-root, since a child is never a root. NodeData cnd = graph.getNodeData(child); cnd.notRoot(); } } });
private Set<Node> getRootSet(Class<?> target, NodeImpl root, Graph gr) { Set<Node> rootSet = null; if (target.isInterface()) { gr.add(root); rootSet = gr.getRoots(); // rootSet just contains root here } else { // Use this class and its superclasses (not Object) as initial roots Class<?> superclass = target; Set<Node> initialRootSet = new HashSet<Node>(); while ((superclass != null) && !superclass.equals(Object.class)) { Node node = new NodeImpl(superclass); gr.add(node); initialRootSet.add(node); superclass = superclass.getSuperclass(); } // Expand all nodes into the graph gr.getRoots(); // remove the roots and find roots again gr.removeAll(initialRootSet); rootSet = gr.getRoots(); } return rootSet; }
private Set<Node> getRootSet(Class<?> target, NodeImpl root, Graph gr) { Set<Node> rootSet = null; if (target.isInterface()) { gr.add(root); rootSet = gr.getRoots(); // rootSet just contains root here } else { // Use this class and its superclasses (not Object) as initial roots Class<?> superclass = target; Set<Node> initialRootSet = new HashSet<Node>(); while ((superclass != null) && !superclass.equals(Object.class)) { Node node = new NodeImpl(superclass); gr.add(node); initialRootSet.add(node); superclass = superclass.getSuperclass(); } // Expand all nodes into the graph gr.getRoots(); // remove the roots and find roots again gr.removeAll(initialRootSet); rootSet = gr.getRoots(); } return rootSet; }