sdk-common / com.tomtom.online.sdk.common.functional / Try / filter

filter

open fun filter(@NonNull predicate: Predicate<in T>): Try<T>!

Returns a Failure if this Try represents a failed computation. Returns a Failure if the value does not satisfy the predicate or an Exception is thrown when testing the predicate. Returns Success otherwise.

Parameters

predicate - Predicate<in T>: used to check the value.

Return
Try<T>!: a Try instance.

abstract fun filter(@NonNull predicate: Predicate<in T>, @NonNull supplier: Supplier<out Throwable!>): Try<T>!

Returns a Failure if this Try represents a failed computation. Returns a Failure if the value does not satisfy the predicate or an Exception is thrown with testing the predicate. Returns Success otherwise.

If the predicate is not satisfied resulting Failure will be taken from the given Supplier.

Parameters

predicate - Predicate<in T>: used to check the value.

supplier - Supplier<out Throwable!>: returns a Throwable used if the value does not satisfy the predicate.

Return
Try<T>!: a Try instance.