Share via


Optional.Filter(IPredicate) Method

Definition

If a value is present, and the value matches the given predicate, returns an Optional describing the value, otherwise returns an empty Optional.

[Android.Runtime.Register("filter", "(Ljava/util/function/Predicate;)Ljava/util/Optional;", "", ApiSince=24)]
public Java.Util.Optional? Filter (Java.Util.Functions.IPredicate? predicate);
[<Android.Runtime.Register("filter", "(Ljava/util/function/Predicate;)Ljava/util/Optional;", "", ApiSince=24)>]
member this.Filter : Java.Util.Functions.IPredicate -> Java.Util.Optional

Parameters

predicate
IPredicate

the predicate to apply to a value, if present

Returns

an Optional describing the value of this Optional, if a value is present and the value matches the given predicate, otherwise an empty Optional

Attributes

Remarks

If a value is present, and the value matches the given predicate, returns an Optional describing the value, otherwise returns an empty Optional.

Java documentation for java.util.Optional.filter(java.util.function.Predicate<? super 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