Udostępnij za pośrednictwem


Optional.FlatMap(IFunction) Method

Definition

If a value is present, returns the result of applying the given Optional-bearing mapping function to the value, otherwise returns an empty Optional.

[Android.Runtime.Register("flatMap", "(Ljava/util/function/Function;)Ljava/util/Optional;", "", ApiSince=24)]
[Java.Interop.JavaTypeParameters(new System.String[] { "U" })]
public Java.Util.Optional? FlatMap (Java.Util.Functions.IFunction? mapper);
[<Android.Runtime.Register("flatMap", "(Ljava/util/function/Function;)Ljava/util/Optional;", "", ApiSince=24)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "U" })>]
member this.FlatMap : Java.Util.Functions.IFunction -> Java.Util.Optional

Parameters

mapper
IFunction

the mapping function to apply to a value, if present

Returns

the result of applying an Optional-bearing mapping function to the value of this Optional, if a value is present, otherwise an empty Optional

Attributes

Remarks

If a value is present, returns the result of applying the given Optional-bearing mapping function to the value, otherwise returns an empty Optional.

This method is similar to #map(Function), but the mapping function is one whose result is already an Optional, and if invoked, flatMap does not wrap it within an additional Optional.

Java documentation for java.util.Optional.flatMap(java.util.function.Function<? super T, ? extends java.util.Optional<? extends U>>).

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