Module com.machinezoo.noexception
Interface OptionalLongPredicate
-
- 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 OptionalLongPredicate
Variation ofLongPredicate
that returnsOptionalBoolean
instead of the raw value.OptionalLongPredicate
is typically obtained fromExceptionHandler.fromLongPredicate(LongPredicate)
, in which case its return value is empty when the underlyingLongPredicate
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongPredicate
orElse(boolean result)
Converts thisOptionalLongPredicate
to plainLongPredicate
using default value.default LongPredicate
orElseGet(BooleanSupplier source)
OptionalBoolean
test(long value)
Variation ofLongPredicate.test(long)
that returnsOptionalBoolean
.
-
-
-
Method Detail
-
test
OptionalBoolean test(long value)
Variation ofLongPredicate.test(long)
that returnsOptionalBoolean
. If thisOptionalLongPredicate
is obtained fromExceptionHandler.fromLongPredicate(LongPredicate)
, theOptionalBoolean
will be empty only if the underlyingLongPredicate
throws. Otherwise the returnedOptionalBoolean
just wraps the return value of underlyingLongPredicate
.- Parameters:
-
value
- seeLongPredicate.test(long)
- Returns:
-
OptionalBoolean
typically wrapping return value ofLongPredicate.test(long)
, or an emptyOptionalBoolean
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongPredicate(LongPredicate)
,LongPredicate.test(long)
-
orElse
default LongPredicate orElse(boolean result)
Converts thisOptionalLongPredicate
to plainLongPredicate
using default value. The returnedLongPredicate
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
LongPredicate
that either unwrapsOptionalBoolean
or returns default value - See Also:
-
orElseGet(BooleanSupplier)
,OptionalBoolean.orElse(boolean)
-
orElseGet
default LongPredicate orElseGet(BooleanSupplier source)
Converts thisOptionalLongPredicate
to plainLongPredicate
using fallbackBooleanSupplier
. The returnedLongPredicate
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
LongPredicate
that either unwrapsOptionalBoolean
or falls back tosource
- See Also:
-
orElse(boolean)
,OptionalBoolean.orElseGet(BooleanSupplier)
-
-