Optimizer { public Parser transform(Parser parser) { Function<Parser, Parser> transformer = transformers.stream().reduce(Function::andThen) .orElse(Function.identity()); return Mirror.of(parser).transform(transformer); }  Optimizer add(Function<Parser, Parser> transformer); Optimizer removeDelegates(); Optimizer removeDuplicates(); Parser transform(Parser parser);  }
@Test public void testNoOptimization() { Parser input = lowerCase().settable().star(); Parser output = new Optimizer().transform(input); assertTrue(output.isEqualTo(input)); }