Everything about

#optional

A series of posts that give you more insight into one of Java's more misunderstood and misused features as well as discussions related to it and its updates in future versions.

I wrote a series of posts about Optional that I recommend you read in the following order:

Intention Revealing Code With Optional#post#clean‑code #java‑8 #optional
Write intention revealing code with Java 8's new type Optional and prevent most NPEs. This is not optional!
The Design of Optional#post#java‑next #java‑8 #optional
A digest of how Optional was introduced in Java 8, summarizing the many discussions about it and their key points based on the mail archive of JSR-335.
Why Isn't Optional Serializable?#post#java‑next #java‑8 #optional #serialization #primitive‑classes
Discussing the reasons for not making Java 8's new type Optional serializable.
Serialize Optional#post#java‑8 #optional #serialization
A summary of why you can't serialize Optional and what can be done to deal with that limitation if necessary.

Then there are a few more posts on the topic that can be read in pretty much any order:

Handling null and Upgrading Past Java 8 - Inside Java Newscast #7#video#migration #optional #switch #project‑valhalla
Dealing with null is never fun, so in this newscast, I explain how to best handle it, what tools can do, and how recent and upcoming language changes help dealing with it. I'll also look at a recent blog post about how Netflix upgraded from Java 8 to 16.
Why Don't They Just... ?! The Deliberations Behind Evolving Java#talk#streams #optional #records #collections
There are many nifty features that Java could have but doesn't. Somewhat surprisingly, there are reasons for that and in this talk I'll discuss those for a few concrete cases as well as the deliberations behind such decisions.
Java's Quirks and Wrong (?) Defaults with Brian Goetz#video#conversation #migration #optional #serialization
Mutability, nullability, serialization, primitives - Nicolai Parlog discusses with Java language architect Brian Goetz why Java is the way it is.
Code-First Java 9 Tutorial#post#java‑9 #migration #streams #optional #collections #j_ms
Showing code for the most important Java 9 features: private interface methods, stream and optional APIs, collection factories, reactive streams, stack walking, multi-release JARs, redirected platform logging, unified logging, the module system, and more. If you're new to Java 9, start here.
Expert Java 8#talk#java‑8 #lambda #streams #optional #default‑methods
With this talk, I help you get the most out of lambdas, Streams, Optionals, and default methods, helping you master Java 8's core features
Why Elvis Should Not Visit Java#post#clean‑code #optional #rant
The desire for the Elvis operator for easier null-handling echoes through the Java community. But due to Java's type system, it should never be introduced!
Java 9 Additions To Optional#post#java‑9 #optional
Java 9 is coming! One of the changes are new methods on Optional: stream(), or(), and ifPresentOrElse(), which considerably improve Optional's API.
Java 8 SE Optional, a strict approach#post#java‑8 #optional
Stephen Colebourne presented his pragmatic approach to using Optional. I argue for a stricter one that gets us further without considerable downsides.
Casting In Java 8 (And Beyond?)#post#java‑8 #optional #streams
Proposal to implement new casting methods on Java's Class. They aim to fulfill the need for improved ways to cast which was created by Java 8.
Roll Your Own Pirate-Elvis Operator#post#java‑8 #lambda #optional
Java has no Elvis operator (or null coalescing operator / null-safe member selection) but with lambda expressions / method references you can roll your own.