java.util.Optional fields

Remi Forax forax at univ-mlv.fr
Fri Sep 21 08:54:28 PDT 2012


On 09/21/2012 05:46 PM, Vitaly Davidovich wrote:
> The main benefit of Optional, to me, is that it clearly tells the caller or
> receiver that this thing may be null; the conventional way is to document
> pre/post conditions, but developers are notorious for not reading docs.
> Returning/taking Optional is "in your face" - the fluent API is a secondary
> convenience/benefit.

Any decent IDEs (at least Eclipse and IDEA) understand @NonNull/@Nullable
and can be easily configured to not compile if you try to call a method on
something that is @Nullable.

Are you suggesting that Optional is a runtime solution to a static 
analysis problem ?

Rémi

>
> Sent from my phone
> On Sep 21, 2012 11:42 AM, "Zhong Yu" <zhong.j.yu at gmail.com> wrote:
>
>> aren't all reference types in Java "optional" already? If "fluent" API
>> is desired, is it possible to add methods to the null type?
>>
>> Zhong
>>
>>



More information about the lambda-dev mailing list