Guava users: do you use @Nullable in your projects? I'd very much like to configure my static analysis tool (findbugs? I think that's the nicest one around?) to assume parameters are non-null unless marked up with @Nullable.

Is it actually worth it to spend the effort doing this, though? Same goes with the Optional<> type. When used correctly, Optional gives you pretty much the same thing as a regular nullable parameter does: the ability to check of the value is present, and an exception if the value is "dereferenced" when it isn't present. What you gain is some readability - it's clear to readers that an Optional<String> can be present or not. You also lose some readability - consumers of your interface must wrap all inputs in Optional.of() or Optional.<String>absent() (yuck).

Additionally, the Optional reference can ITSELF be null...

It seems to me that the best thing to do is add the @ParametersAreNonnullByDefault package annotation to all your packages, explicitly use the @Nullable annotation on optional parameters, and forget the Optional type.

Thoughts?

Looking at you, +Louis Wasserman... :)
Shared publiclyView activity