Just use another language if you want pattern matching so badly. Twisting Java to look like Scala doesn't do the language justice.
Re:Pattern Matching for Java
by RhodesianHunter on Thursday April 20, 2017 @08:52AM
(#14156178)
You act as if what op described must be the entirety of their code base. What if pattern matching is just a small part of a larger problem better solved with Java?
Re:Pattern Matching for Java
by adrianmsmith on Thursday April 20, 2017 @03:42PM
(#14160107)
It's not so easy to just choose another language; there might be hundreds of thousands of lines of Java already written. In that case it's better make the best of a bad situation by doing something like this, than not even trying.
You could probably extend the second approach to get something close to the arbitrary predicates that pattern matching would provide, but the syntax wouldn't be nearly a clean as having it in the language.