ExpressionParser { static Parser<Expression> simpleCase(Parser<Expression> expr) { return Parsers.sequence( term("case").next(expr), whenThens(expr, expr), term("else").next(expr).optional().followedBy(term("end")), SimpleCaseExpression::new); }    }
@Test public void testSimpleCase() { Parser<Expression> parser = ExpressionParser.simpleCase(NUMBER); TerminalParserTest.assertParser(parser, "case 1 when 1 then 2 else 3 end", simpleCase(number(1), number(1), number(2), number(3))); TerminalParserTest.assertParser(parser, "case 1 when 1 then 2 end", simpleCase(number(1), number(1), number(2), null)); }