T
- see Predicate
@FunctionalInterface public interface OptionalPredicate<T>
Predicate
that returns OptionalBoolean
instead of the raw value. OptionalPredicate
is typically obtained from ExceptionHandler.predicate(Predicate)
, in which case its return value is empty when the underlying Predicate
throws an exception. See noexception tutorial.
ExceptionHandler.predicate(Predicate)
, Predicate
Modifier and Type | Method and Description |
---|---|
default Predicate<T> |
orElse(boolean result)
Converts this OptionalPredicate to plain Predicate using default value.
|
default Predicate<T> |
orElseGet(BooleanSupplier source)
|
OptionalBoolean |
test(T t)
Variation of Predicate.test(Object) that returns OptionalBoolean .
|
OptionalBoolean test(T t)
Predicate.test(Object)
that returns OptionalBoolean
. If this OptionalPredicate
is obtained from ExceptionHandler.predicate(Predicate)
, the OptionalBoolean
will be empty only if the underlying Predicate
throws. Otherwise the returned OptionalBoolean
just wraps the return value of underlying Predicate
.
t
- see Predicate.test(Object)
OptionalBoolean
typically wrapping return value of Predicate.test(Object)
, or an empty OptionalBoolean
(typically signifying an exception)
ExceptionHandler.predicate(Predicate)
, Predicate.test(Object)
default Predicate<T> orElse(boolean result)
OptionalPredicate
to plain Predicate
using default value. The returned Predicate
will unwrap present value from the OptionalBoolean
if possible, or return result
if the OptionalBoolean
is empty.
result
- default value to return instead of an empty OptionalBoolean
Predicate
that either unwraps OptionalBoolean
or returns default value
orElseGet(BooleanSupplier)
, OptionalBoolean.orElse(boolean)
default Predicate<T> orElseGet(BooleanSupplier source)
OptionalPredicate
to plain Predicate
using fallback BooleanSupplier
. The returned Predicate
will unwrap present value from the OptionalBoolean
if possible, or fall back to calling source
if the OptionalBoolean
is empty.
source
- BooleanSupplier
to query for fallback value when OptionalBoolean
is empty
Predicate
that either unwraps OptionalBoolean
or falls back to source
orElse(boolean)
, OptionalBoolean.orElseGet(BooleanSupplier)
Copyright © 2017–2020 Robert Važan. All rights reserved.