Sealed interface switches are a direct replacement for the visitor pattern, so it just depends on how many places you have where you have a small set of types and a lot of operations on those types.
Totally, I think you nailed it down. I don’t think that an average Java project has enough of those to justify a language change, obviously the committee overseeing Java development disagrees and based on the comments and a lot of Java devs disagree with me too, which is totally cool.
View all comments
Show parent comment
7
u/OwnBreakfast1114 Feb 18 '26
Sealed interface switches are a direct replacement for the visitor pattern, so it just depends on how many places you have where you have a small set of types and a lot of operations on those types.