A static null-coalescing method
Emre Kaplan
emr3kp at gmail.com
Tue Oct 29 16:36:27 UTC 2024
Hi,
Why wouldn't requireNonNullElse(o1, requireNonNull(o2)) or
> requireNonNull(requireNonNullElse(o1, o2)) suffice?
>
Because requireNonNullElse requires both arguments are not null. There
isn't a method for second argument to return even if it is null.
Regards,
Mark Reinhold <mark.reinhold at oracle.com>, 29 Eki 2024 Sal, 17:23 tarihinde
şunu yazdı:
> 2024/10/28 15:40:55 -0400, Emre Kaplan <emr3kp at gmail.com>:
> > I think java.util.Optional class should have a static method named like
> > getOrDefault(Object o, Object default)
>
> This discussion would be more appropriate on the core-libs-dev list.
>
> - Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20241029/486f347a/attachment-0001.htm>
More information about the jdk-dev
mailing list