ParseGraph implements ParseItem { protected ParseGraph closeBranch() { if (!branched) { throw new IllegalStateException("Cannot close branch that is not open."); } if (head.asGraph().branched) { return new ParseGraph(head.asGraph().closeBranch(), tail, definition, true); } return new ParseGraph(head, tail, definition, false); } private  ParseGraph(final Token definition); private  ParseGraph(final ParseItem head, final ParseGraph tail, final Token definition, final boolean branched); private  ParseGraph(final ParseItem head, final ParseGraph tail, final Token definition); boolean isEmpty(); Optional<ParseValue> current(); @Override boolean isGraph(); @Override ParseGraph asGraph(); @Override Token getDefinition(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); final ParseItem head; final ParseGraph tail; final boolean branched; final Token definition; final long size; static final Token NONE; static final ParseGraph EMPTY; }
@Test public void testCloseNotBranched() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Cannot close branch that is not open."); EMPTY.closeBranch(); }