optional is not how algebraic data types are implemented in Java. Basically it's the combination of sealed types and records.
Until they implement member patterns. https://openjdk.org/projects/amber/design-notes/patterns/tow...
Until they implement member patterns. https://openjdk.org/projects/amber/design-notes/patterns/tow...