RegexBaseVisitor implements RegexVisitor { protected void after(RegexParseResult regexParseResult) { }  @Override void visit(RegexParseResult regexParseResult); @Override void visitPlainCharacter(PlainCharacterTree tree); @Override void visitUnicodeCodePoint(UnicodeCodePointTree tree); @Override void visitSequence(SequenceTree tree); @Override void visitDisjunction(DisjunctionTree tree); @Override void visitCapturingGroup(CapturingGroupTree tree); @Override final void visitNonCapturingGroup(NonCapturingGroupTree tree); @Override void visitAtomicGroup(AtomicGroupTree tree); @Override void visitLookAround(LookAroundTree tree); @Override void visitBackReference(BackReferenceTree tree); @Override void visitRepetition(RepetitionTree tree); @Override void visitCharacterClass(CharacterClassTree tree); @Override void visitCharacterRange(CharacterRangeTree tree); @Override void visitCharacterClassUnion(CharacterClassUnionTree tree); @Override void visitCharacterClassIntersection(CharacterClassIntersectionTree tree); @Override void visitDot(DotTree tree); @Override void visitEscapedCharacterClass(EscapedCharacterClassTree tree); @Override void visitBoundary(BoundaryTree boundaryTree); @Override void visitMiscEscapeSequence(MiscEscapeSequenceTree tree);  }
@Test void after() { class Visitor extends RegexBaseVisitor { boolean visitedAfter = false; boolean visitedSequence = false; @Override public void visitSequence(SequenceTree tree) { visitedSequence = true; assertThat(visitedAfter).isFalse(); super.visitSequence(tree); } @Override protected void after(RegexParseResult regexParseResult) { visitedAfter = true; assertThat(visitedSequence).isTrue(); super.before(regexParseResult); } } Visitor visitor = new Visitor(); visitor.visit(RegexParserTestUtils.assertSuccessfulParseResult("abc")); assertThat(visitor.visitedAfter).isTrue(); assertThat(visitor.visitedSequence).isTrue(); }