Java’s Sealed Classes Meet the Visitor Pattern
Replacing a classic GoF pattern with pattern matching: a before and after refactor of a Visitor hierarchy, collapsed into a sealed interface and an exhaustive switch expression. The Visitor pattern has been part of every Java developer’s toolkit…