Module com.machinezoo.noexception
Interface OptionalIntPredicate
-
- 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 OptionalIntPredicate
Variation ofIntPredicatethat returnsOptionalBooleaninstead of the raw value.OptionalIntPredicateis typically obtained fromExceptionHandler.fromIntPredicate(IntPredicate), in which case its return value is empty when the underlyingIntPredicatethrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IntPredicateorElse(boolean result)Converts thisOptionalIntPredicateto plainIntPredicateusing default value.default IntPredicateorElseGet(BooleanSupplier source)OptionalBooleantest(int value)Variation ofIntPredicate.test(int)that returnsOptionalBoolean.
-
-
-
Method Detail
-
test
OptionalBoolean test(int value)
Variation ofIntPredicate.test(int)that returnsOptionalBoolean. If thisOptionalIntPredicateis obtained fromExceptionHandler.fromIntPredicate(IntPredicate), theOptionalBooleanwill be empty only if the underlyingIntPredicatethrows. Otherwise the returnedOptionalBooleanjust wraps the return value of underlyingIntPredicate.- Parameters:
-
value- seeIntPredicate.test(int) - Returns:
-
OptionalBooleantypically wrapping return value ofIntPredicate.test(int), or an emptyOptionalBoolean(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntPredicate(IntPredicate),IntPredicate.test(int)
-
orElse
default IntPredicate orElse(boolean result)
Converts thisOptionalIntPredicateto plainIntPredicateusing default value. The returnedIntPredicatewill unwrap present value from theOptionalBooleanif possible, or returnresultif theOptionalBooleanis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalBoolean - Returns:
-
plain
IntPredicatethat either unwrapsOptionalBooleanor returns default value - See Also:
-
orElseGet(BooleanSupplier),OptionalBoolean.orElse(boolean)
-
orElseGet
default IntPredicate orElseGet(BooleanSupplier source)
Converts thisOptionalIntPredicateto plainIntPredicateusing fallbackBooleanSupplier. The returnedIntPredicatewill unwrap present value from theOptionalBooleanif possible, or fall back to callingsourceif theOptionalBooleanis empty.- Parameters:
-
source-BooleanSupplierto query for fallback value whenOptionalBooleanis empty - Returns:
-
plain
IntPredicatethat either unwrapsOptionalBooleanor falls back tosource - See Also:
-
orElse(boolean),OptionalBoolean.orElseGet(BooleanSupplier)
-
-