The Guava’s aficionado have been dealing with the concept of Optional for a while (since Guava 10 actually, it’s been 3 years). As usual, I’m not going to talk about how to use Optional, I’m more interested in the way Google implemented the concept, the Java 8 implementation and the differences between the two of them.
It took two years and a half to feel this gap in the JDK, and the choices made by the JDK expert groups are interesting in terms of implementation but also naming convention.
But let’s start with the Guava implementation.
Optional is an abstract class, implementing Serializable. It might look like a small detail, but it’s not, I’ll come back to this point while talking about the Java 8 implementation.