IfExp extends StandaloneExp { public void addElseBody(StandaloneExp body) { if (elseBody == null) { elseBody = body; } else { elseBody = elseBody.append(body); } } IfExp(NestedExp condition); void addIfBody(StandaloneExp body); void addElseBody(StandaloneExp body); @Override String getCode();  }
@Test public void testAddElseBody() { IfExp ifExp = new IfExp(BooleanExp.TRUE); ifExp.addElseBody(new IfExp(BooleanExp.TRUE)); assertEquals("\nif (true) {\n} else {\nif (true) {\n}\n}", ifExp.getCode()); }