> (to avoid ambiguity about whether a call is to the (T, T) overload or the (T, Supplier<T>) overload)
ali963sy opened this issue · comments
> (to avoid ambiguity about whether a call is to the (T, T) overload or the (T, Supplier<T>) overload)
Is there an actual problem adding firstNonNull
overload? I'd stick with that precise name.
In contrast to JDKs requireNonNullElseGet(obj, supplier)
Guava should always check second parameter for null to follow its null-hostile policy.
Originally posted by @bjmi in #6283 (comment)
I think we would still want to use a different name, as @cpovirk mentioned above. Otherwise there might be compile-time errors when calling firstNonNull(supplier, () -> otherSupplier)
.
And Objects.requireNonNullElseGet(T, Supplier<? extends T>)
does in fact throw if the second parameter is null or returns null.
Unless there is a reason other than the name (or having a method also in MoreObjects
for discoverability), I don't think we'll add this method.