An aside: Before java 15 to remedy this people used the "type safe visitor" pattern. I recommend not learning that for your sanity, but if you are curious you can look at code ANTLR generates - its all a large hierarchy of differently "shaped" data structures.
Source : section 2, What is the point of a “sealed interface” in Java?
In the case where we use Visitor to avoid multiple instanceof :
- What is the advantage to use pattern Visitor rather than using sealed type with switch pattern matching ?
- What is the advantage to use sealed with switch pattern matching type rather than using Visitor ?
- Should we stop using Visitor ?
Aucun commentaire:
Enregistrer un commentaire