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 ofIntPredicate
that returnsOptionalBoolean
instead of the raw value.OptionalIntPredicate
is typically obtained fromExceptionHandler.fromIntPredicate(IntPredicate)
, in which case its return value is empty when the underlyingIntPredicate
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IntPredicate
orElse(boolean result)
Converts thisOptionalIntPredicate
to plainIntPredicate
using default value.default IntPredicate
orElseGet(BooleanSupplier source)
OptionalBoolean
test(int value)
Variation ofIntPredicate.test(int)
that returnsOptionalBoolean
.
-
-
-
Method Detail
-
test
OptionalBoolean test(int value)
Variation ofIntPredicate.test(int)
that returnsOptionalBoolean
. If thisOptionalIntPredicate
is obtained fromExceptionHandler.fromIntPredicate(IntPredicate)
, theOptionalBoolean
will be empty only if the underlyingIntPredicate
throws. Otherwise the returnedOptionalBoolean
just wraps the return value of underlyingIntPredicate
.- Parameters:
-
value
- seeIntPredicate.test(int)
- Returns:
-
OptionalBoolean
typically 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 thisOptionalIntPredicate
to plainIntPredicate
using default value. The returnedIntPredicate
will unwrap present value from theOptionalBoolean
if possible, or returnresult
if theOptionalBoolean
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalBoolean
- Returns:
-
plain
IntPredicate
that either unwrapsOptionalBoolean
or returns default value - See Also:
-
orElseGet(BooleanSupplier)
,OptionalBoolean.orElse(boolean)
-
orElseGet
default IntPredicate orElseGet(BooleanSupplier source)
Converts thisOptionalIntPredicate
to plainIntPredicate
using fallbackBooleanSupplier
. The returnedIntPredicate
will unwrap present value from theOptionalBoolean
if possible, or fall back to callingsource
if theOptionalBoolean
is empty.- Parameters:
-
source
-BooleanSupplier
to query for fallback value whenOptionalBoolean
is empty - Returns:
-
plain
IntPredicate
that either unwrapsOptionalBoolean
or falls back tosource
- See Also:
-
orElse(boolean)
,OptionalBoolean.orElseGet(BooleanSupplier)
-
-