Module com.machinezoo.noexception
Interface OptionalBiPredicate<T,U>
-
- Type Parameters:
-
T- seeBiPredicate -
U- seeBiPredicate
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface OptionalBiPredicate<T,U>
Variation ofBiPredicatethat returnsOptionalBooleaninstead of the raw value.OptionalBiPredicateis typically obtained fromExceptionHandler.fromBiPredicate(BiPredicate), in which case its return value is empty when the underlyingBiPredicatethrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BiPredicate<T,U>orElse(boolean result)Converts thisOptionalBiPredicateto plainBiPredicateusing default value.default BiPredicate<T,U>orElseGet(BooleanSupplier source)OptionalBooleantest(T t, U u)Variation ofBiPredicate.test(Object, Object)that returnsOptionalBoolean.
-
-
-
Method Detail
-
test
OptionalBoolean test(T t, U u)
Variation ofBiPredicate.test(Object, Object)that returnsOptionalBoolean. If thisOptionalBiPredicateis obtained fromExceptionHandler.fromBiPredicate(BiPredicate), theOptionalBooleanwill be empty only if the underlyingBiPredicatethrows. Otherwise the returnedOptionalBooleanjust wraps the return value of underlyingBiPredicate.- Parameters:
-
t- seeBiPredicate.test(Object, Object) -
u- seeBiPredicate.test(Object, Object) - Returns:
-
OptionalBooleantypically wrapping return value ofBiPredicate.test(Object, Object), or an emptyOptionalBoolean(typically signifying an exception) - See Also:
-
ExceptionHandler.fromBiPredicate(BiPredicate),BiPredicate.test(Object, Object)
-
orElse
default BiPredicate<T,U> orElse(boolean result)
Converts thisOptionalBiPredicateto plainBiPredicateusing default value. The returnedBiPredicatewill unwrap present value from theOptionalBooleanif possible, or returnresultif theOptionalBooleanis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalBoolean - Returns:
-
plain
BiPredicatethat either unwrapsOptionalBooleanor returns default value - See Also:
-
orElseGet(BooleanSupplier),OptionalBoolean.orElse(boolean)
-
orElseGet
default BiPredicate<T,U> orElseGet(BooleanSupplier source)
Converts thisOptionalBiPredicateto plainBiPredicateusing fallbackBooleanSupplier. The returnedBiPredicatewill unwrap present value from theOptionalBooleanif possible, or fall back to callingsourceif theOptionalBooleanis empty.- Parameters:
-
source-BooleanSupplierto query for fallback value whenOptionalBooleanis empty - Returns:
-
plain
BiPredicatethat either unwrapsOptionalBooleanor falls back tosource - See Also:
-
orElse(boolean),OptionalBoolean.orElseGet(BooleanSupplier)
-
-