net.sf.jga.fn
public interface Visitor
jga uses the AcyclicVisitor
pattern to provide a structure for implementing Visitor. Within jga, each
class that implements Visitable does so with the following boilerplate:
public class Foo implements Visitable public void accept(net.sf.jga.fn.Visitor v) { if (v instanceof Foo.Visitor) ((Foo.Visitor)v).visit(this); } public interface Visitor extends net.sf.jga.fn.Visitor { public void visit(Foo host); }Implementations of Visitor will declare suport for a given class by implementing that class' Visitor interface.
public class FooBarCounter implements Foo.Visitor, Bar.Visitor { private int count = 0; public int getCount() { return count; } public void visit(Visitable host) {} public void visit(Foo host) { ++count; } public void visit(Bar host) { ++count; } }
Copyright © 2002 David A. Hall
Method Summary | |
---|---|
void | visit(Visitable visitable)
Call-back method, called by the Visitable object in response to a
call to its accept(Visitor) method. |
accept(Visitor)
method.