There are many articles that explain the broad applications of Java 8’s new Optional
class (e.g., Tired of Null Pointer Exceptions? Consider Using Java SE 8’s Optional
!), but they focus on how authors can use Optional
to improve the design of their own APIs. I want to talk about how Optional
can be used to protect us from the APIs we didn’t write.