@Test(expected = IndexOutOfBoundsException.class) public void getChildBad() { makeTernary().getChild(3); }
@Override public Expr getChild(int index) { if (index == 0) { return test; } if (index == 1) { return thenExpr; } if (index == 2) { return elseExpr; } throw new IndexOutOfBoundsException("Index for TernaryExpr must be 0, 1 or 2"); }
TernaryExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return test; } if (index == 1) { return thenExpr; } if (index == 2) { return elseExpr; } throw new IndexOutOfBoundsException("Index for TernaryExpr must be 0, 1 or 2"); } }
TernaryExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return test; } if (index == 1) { return thenExpr; } if (index == 2) { return elseExpr; } throw new IndexOutOfBoundsException("Index for TernaryExpr must be 0, 1 or 2"); } TernaryExpr(Expr test, Expr thenExpr, Expr elseExpr); }
TernaryExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return test; } if (index == 1) { return thenExpr; } if (index == 2) { return elseExpr; } throw new IndexOutOfBoundsException("Index for TernaryExpr must be 0, 1 or 2"); } 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(); }
TernaryExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return test; } if (index == 1) { return thenExpr; } if (index == 2) { return elseExpr; } throw new IndexOutOfBoundsException("Index for TernaryExpr must be 0, 1 or 2"); } 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();  }