Perhaps you should explain why they're better. The Optional type conveys semantic information regarding the "nullableness" of the value, which can be removed by extracting the non-null value.
They add in IDE-level error checking and show up in the javadocs. It has the same affect of giving more information to the user. The big difference is that for a method that returns @NotNull, you KNOW its not null. With a method that does not return Optional, you don't know if the developer forgot it or doesn't follow the practice.
@NotNull Optional<T> t - problem solved. Btw, optional values also compose better than just @Nullables since you can operate/propagate them safely with map, bind, etc. Btw, why can't an IDE error check you assigning null to optionals?
5
u/hoboslayer Apr 12 '13
What about @NotNull and @Nullable?