Quantcast
Channel: Optional – blog@CodeFX
Browsing latest articles
Browse All 9 View Live

Image may be NSFW.
Clik here to view.

Intention Revealing Code With Java 8’s New Type Optional

Java 8 introduced a type Optional<T>, which can be used to handle potentially missing values. It does so by wrapping a reference (which might be null) and providing some nice methods to interact...

View Article



Image may be NSFW.
Clik here to view.

The Design of Optional

In my last post I promoted using Java 8’s new type Optional nearly everywhere as a replacement for null. As it turns out, this puts me at odds with with the expert group which introduced the type. This...

View Article

Image may be NSFW.
Clik here to view.

Why Isn’t Optional Serializable?

Java 8’s new type Optional was met with different reactions and one point of criticism is that it isn’t serializable. Let’s have a look at the reasons for that. A future post will then show how to...

View Article

Image may be NSFW.
Clik here to view.

Serialize Optional

In a recent post I explained why we can’t serialize Optional. But what if, after all that, we still really, really want to? Let’s see how to come as close as possible. Update This is part of a series...

View Article

Image may be NSFW.
Clik here to view.

Casting In Java 8 (And Beyond?)

Casting an instance to a type reeks of bad design. Still, there are situations where there is no other choice. The ability to do this has hence been part of Java since day one. I think Java 8 created a...

View Article


Image may be NSFW.
Clik here to view.

Java 8 SE Optional, a strict approach

About two weeks ago Stephen Colebourne presented his pragmatic approach to using Optional. If you read it, you might have guessed from my previous recommendations that I don’t agree. Overview I have to...

View Article

Image may be NSFW.
Clik here to view.

Roll Your Own Pirate-Elvis Operator

So, Java doesn’t have an Elvis operator (or, as it is more formally known, null coalescing operator or null-safe member selection) … While I personally don’t much care about it, some people seem to...

View Article

Image may be NSFW.
Clik here to view.

Java 9 Additions To Optional

Wow, people were really interested in Java 9’s additions to the Stream API. Want some more? Let’s look at … Optional Optional::stream This one requires no explanation: Stream<T> stream(); Finally...

View Article


Image may be NSFW.
Clik here to view.

Why Elvis Should Not Visit Java

I was recently involved in quite a long Twitter discussion regarding Java’s Optional, type systems that distinguish nullable and non-nullable types and the the Elvis operator, which allows null-safe...

View Article

Browsing latest articles
Browse All 9 View Live




Latest Images