Objects.RequireNonNullElseGet(Object, ISupplier) Method

Definition

Returns the first argument if it is non-null and otherwise returns the non-null value of supplier.get().

[Android.Runtime.Register("requireNonNullElseGet", "(Ljava/lang/Object;Ljava/util/function/Supplier;)Ljava/lang/Object;", "", ApiSince=30)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static Java.Lang.Object RequireNonNullElseGet (Java.Lang.Object? obj, Java.Util.Functions.ISupplier supplier);
[<Android.Runtime.Register("requireNonNullElseGet", "(Ljava/lang/Object;Ljava/util/function/Supplier;)Ljava/lang/Object;", "", ApiSince=30)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member RequireNonNullElseGet : Java.Lang.Object * Java.Util.Functions.ISupplier -> Java.Lang.Object

Parameters

obj
Object

an object

supplier
ISupplier

of a non-null object to return if the first argument is null

Returns

the first argument if it is non-null and otherwise the value from supplier.get() if it is non-null

Attributes

Remarks

Returns the first argument if it is non-null and otherwise returns the non-null value of supplier.get().

Added in 9.

Java documentation for java.util.Objects.requireNonNullElseGet(T, java.util.function.Supplier<? extends T>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to