Optional.or name <was> Re: RFR 8080418 Add Optional.or()
Paul Sandoz
paul.sandoz at oracle.com
Mon Oct 12 07:48:13 UTC 2015
> On 25 Sep 2015, at 12:58, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
>
> Hi,
>
> Please review this change to add a method Optional.or that allows one to better compose optionals:
>
> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8080418-optional-or/webrev/
>
> I also took the opportunity to clear up the JavaDoc, it was a little inconsistent and i personally found it harder to read in source code.
>
Now that the overall documentation changes and functional behaviour of Optional.or has been agreed i would like to see if we can find a better name, suggestions welcome, so lets get our paint brushes out :-)
I suggest we avoid commenting on comments, otherwise this thread could get out of control.
“Optional.or” is the best name so far i have come up with. The “orElse” prefix is reversed for terminal methods and i don’t want to overload that.
--
Alternative suggestions:
- “Optional.otherwise”
A bit of a mouthful, but reasonably accurate
- “Optional.mapElse"
The name is not entirely accurate since it accepts a Suppler<T> not a T, a more accurate name would be the following alternative.
- “Optional.flatMapElse"
This name is likely to confuse.
Paul.
More information about the core-libs-dev
mailing list