RFR 9: 8138963 : java.lang.Objects new method to default to non-null

Stephen Colebourne scolebourne at joda.org
Wed Oct 7 22:44:23 UTC 2015

On 7 October 2015 at 23:24, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> Please consider and comment:
>     <T> T nonNullOf(T obj, T defaultObj);
>     <T> T nonNullOf(T, obj, Supplier<T> defaultSupplier);
> Details are in the updated webrev:
>      http://cr.openjdk.java.net/~rriggs/webrev-object-non-null/

I think I can live with that name.

The Javadoc for the supplier variant needs to mention that an NPE is
thrown if the supplier itself is null.

@throws NullPointerException if {@code obj} is null and either {@code
supplier} is null or the {@code supplier.get()} value is {@code null}


More information about the core-libs-dev mailing list