RFR 8080418 Add Optional.or()
Tagir F. Valeev
amaembo at gmail.com
Sat Sep 26 08:32:49 UTC 2015
>> Quite interesting and long awaited features (at least according to
>> StackOverflow questions).
PS> All of them? or just the first?
The first one is definitely the most requested feature. However,
additional methods for primitive optionals were requested at least
Something like mapOrElseGet was implicitly requested here
(though it's more look like ifPresentOrElse)
>> Isn't it a good idea to provide also a way
>> to transfer between Optional types like "mapToInt", "mapToObj", etc.,
>> like it's done in Stream API?
PS> I don’t wanna go there, my response is transform Optional* into a
PS> *Stream. An argument for adding mapOrElseGet (notice that the
PS> primitive variants return U) is that other functionality can be composed from it.
Probably then it's better instead of adding map, filter, etc. just add
single "boxed()" method to convert OptionalDouble to Optional<Double>,
etc.? So if somebody really wants to chain optional calls, let them do
the boxing and use the features of normal Optional.
With best regards,
More information about the core-libs-dev