In the chase for non-trivial examples to illustrate possible usage of JEP 305, some people might have gone too far, I guess. In particular into the more challenging area of the
equals() method, present in all Java objects.
Java 14 has a lot of new features. One of them (as preview feature) is pattern matching with
instanceof. Some people programming in languages supporting the functional paradigm to some extent, e.g. Scala, Kotlin (not to mention Haskell) jumped high, full of joy ‘Yay, we gonna have
when, extracting data, guards, deconstructors in companion objects and more!’
Below you can find a piece of code written in Java. I’d like to ask you one thing: please don’t run this code before you try to answer.