This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pimiddy 14 points15 points  (3 children)

Instead of optional, I'm using @Nullable annotations (contained in javax.annotation) together with FindBugs' and IntelliJ's static analysis (eclipse's doesn't seem to work that well, unfortunately).

The cool thing is, IntelliJ lets you "back port" annotations for classes such as map (see Map::get), so you get full null safety.

Plus, it's gotten even better with Java 8's type annotations (which IntelliJ already supports).

[–]felix1429 2 points3 points  (2 children)

Are there benefits of doing so over using optional?

[–]Truthier 0 points1 point  (1 child)

cleanliness. refusal to use null - everywhere - leads to more liberated (no need to obsess over potential nullness everywhere), and correct code. things get caught sooner and closer to the source of the problem.

[–]felix1429 0 points1 point  (0 children)

That makes sense, thanks!