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 ofLongPredicatethat returnsOptionalBooleaninstead of the raw value.OptionalLongPredicateis typically obtained fromExceptionHandler.fromLongPredicate(LongPredicate), in which case its return value is empty when the underlyingLongPredicatethrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongPredicateorElse(boolean result)Converts thisOptionalLongPredicateto plainLongPredicateusing default value.default LongPredicateorElseGet(BooleanSupplier source)OptionalBooleantest(long value)Variation ofLongPredicate.test(long)that returnsOptionalBoolean.
-
-
-
Method Detail
-
test
OptionalBoolean test(long value)
Variation ofLongPredicate.test(long)that returnsOptionalBoolean. If thisOptionalLongPredicateis obtained fromExceptionHandler.fromLongPredicate(LongPredicate), theOptionalBooleanwill be empty only if the underlyingLongPredicatethrows. Otherwise the returnedOptionalBooleanjust wraps the return value of underlyingLongPredicate.- Parameters:
-
value- seeLongPredicate.test(long) - Returns:
-
OptionalBooleantypically 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 thisOptionalLongPredicateto plainLongPredicateusing default value. The returnedLongPredicatewill unwrap present value from theOptionalBooleanif possible, or returnresultif theOptionalBooleanis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalBoolean - Returns:
-
plain
LongPredicatethat either unwrapsOptionalBooleanor returns default value - See Also:
-
orElseGet(BooleanSupplier),OptionalBoolean.orElse(boolean)
-
orElseGet
default LongPredicate orElseGet(BooleanSupplier source)
Converts thisOptionalLongPredicateto plainLongPredicateusing fallbackBooleanSupplier. The returnedLongPredicatewill unwrap present value from theOptionalBooleanif possible, or fall back to callingsourceif theOptionalBooleanis empty.- Parameters:
-
source-BooleanSupplierto query for fallback value whenOptionalBooleanis empty - Returns:
-
plain
LongPredicatethat either unwrapsOptionalBooleanor falls back tosource - See Also:
-
orElse(boolean),OptionalBoolean.orElseGet(BooleanSupplier)
-
-