Optional.OrElseThrow Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
OrElseThrow() |
If a value is present, returns the value, otherwise throws
|
OrElseThrow(ISupplier) |
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function. |
OrElseThrow()
If a value is present, returns the value, otherwise throws
NoSuchElementException
.
[Android.Runtime.Register("orElseThrow", "()Ljava/lang/Object;", "", ApiSince=33)]
public Java.Lang.Object? OrElseThrow ();
[<Android.Runtime.Register("orElseThrow", "()Ljava/lang/Object;", "", ApiSince=33)>]
member this.OrElseThrow : unit -> Java.Lang.Object
Returns
the non-null
value described by this Optional
- Attributes
Remarks
If a value is present, returns the value, otherwise throws NoSuchElementException
.
Added in 10.
Java documentation for java.util.Optional.orElseThrow()
.
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
OrElseThrow(ISupplier)
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
[Android.Runtime.Register("orElseThrow", "(Ljava/util/function/Supplier;)Ljava/lang/Object;", "", ApiSince=24)]
[Java.Interop.JavaTypeParameters(new System.String[] { "X extends java.lang.Throwable" })]
public Java.Lang.Object? OrElseThrow (Java.Util.Functions.ISupplier? exceptionSupplier);
[<Android.Runtime.Register("orElseThrow", "(Ljava/util/function/Supplier;)Ljava/lang/Object;", "", ApiSince=24)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "X extends java.lang.Throwable" })>]
member this.OrElseThrow : Java.Util.Functions.ISupplier -> Java.Lang.Object
Parameters
- exceptionSupplier
- ISupplier
the supplying function that produces an exception to be thrown
Returns
the value, if present
- Attributes
Remarks
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
Java documentation for java.util.Optional.orElseThrow(java.util.function.Supplier<? extends X>)
.
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.