Main { {{ static ClassGraph cg; public static void main(String args[]) throws Exception { cg = new ClassGraph(true, false); ClassGraph cgWT = new ClassGraph(Main.cg, "from Input bypassing -> *,tail,* to *"); cg = cgWT; Input c = Input.parse(System.in); c.display(); System.out.println(); System.out.println("original Input-object"); c.print(); System.out.println(); c.normals(); c.normals2(); c.updateInput(); c.print(); System.out.println(); c.normals(); c.normals2(); System.out.println(); TraversalGraph tg = new TraversalGraph( "from Input via Provided to Normal", cg); System.out.println(tg); System.out.println(" done "); } }} } Input { void display() to * (DisplayVisitor); void print() to * (PrintVisitor); } Normal { void print() to * (PrintVisitor); } Input { {{ void normals(){ System.out.println(" all Normal objects reachable from Input "); Main.cg.traverse(this,"from Input to Normal", new Visitor() { public void before (Normal host) { host.print(); System.out.println(); } }); } void normals2(){ System.out.println(" all Normal objects reachable from Input version 2"); List lstNormals = Main.cg.gather(this, "from Input to Normal"); Iterator iter = lstNormals.iterator(); while (iter.hasNext()) { Normal host = (Normal) iter.next(); host.print(); System.out.println(); } } void updateInput(){ System.out.println(" update Provided: add one Normal-object "); Main.cg.traverse(this,"from Input to Provided", new Visitor() { public void before (Provided host) { host.get_fms().addElement(new Normal()); } }); } }} }