optional is not how algebraic data types are implemented in Java. Basically it's the combination of sealed types and records.