TernaryExpr extends Expr { @Override public void accept(IAstVisitor visitor) { visitor.visitTernaryExpr(this); } TernaryExpr(Expr test, Expr thenExpr, Expr elseExpr); Expr getTest(); Expr getThenExpr(); Expr getElseExpr(); @Override void accept(IAstVisitor visitor); @Override TernaryExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }
@Test public void accept() throws Exception { TernaryExpr te = new TernaryExpr( makeTernary().clone(), makeTernary().clone(), makeTernary().clone()); assertEquals(4, new StandardVisitor() { private int numTernaries; @Override public void visitTernaryExpr(TernaryExpr ternaryExpr) { super.visitTernaryExpr(ternaryExpr); numTernaries++; } public int getNumTernaries(TernaryExpr node) { numTernaries = 0; visit(node); return numTernaries; } }.getNumTernaries(te) ); }