Module com.machinezoo.noexception
Interface OptionalLongBinaryOperator
-
- 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 OptionalLongBinaryOperator
Variation ofLongBinaryOperator
that returnsOptionalLong
instead of the raw value.OptionalLongBinaryOperator
is typically obtained fromExceptionHandler.fromLongBinaryOperator(LongBinaryOperator)
, in which case its return value is empty when the underlyingLongBinaryOperator
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
apply(long left, long right)
Variation ofLongBinaryOperator.applyAsLong(long, long)
that returnsOptionalLong
.default LongBinaryOperator
orElse(long result)
Converts thisOptionalLongBinaryOperator
to plainLongBinaryOperator
using default value.default LongBinaryOperator
orElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(long left, long right)
Variation ofLongBinaryOperator.applyAsLong(long, long)
that returnsOptionalLong
. If thisOptionalLongBinaryOperator
is obtained fromExceptionHandler.fromLongBinaryOperator(LongBinaryOperator)
, theOptionalLong
will be empty only if the underlyingLongBinaryOperator
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingLongBinaryOperator
.- Parameters:
-
left
- seeLongBinaryOperator.applyAsLong(long, long)
-
right
- seeLongBinaryOperator.applyAsLong(long, long)
- Returns:
-
OptionalLong
typically wrapping return value ofLongBinaryOperator.applyAsLong(long, long)
, or an emptyOptionalLong
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongBinaryOperator(LongBinaryOperator)
,LongBinaryOperator.applyAsLong(long, long)
-
orElse
default LongBinaryOperator orElse(long result)
Converts thisOptionalLongBinaryOperator
to plainLongBinaryOperator
using default value. The returnedLongBinaryOperator
will unwrap present value from theOptionalLong
if possible, or returnresult
if theOptionalLong
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalLong
- Returns:
-
plain
LongBinaryOperator
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default LongBinaryOperator orElseGet(LongSupplier source)
Converts thisOptionalLongBinaryOperator
to plainLongBinaryOperator
using fallbackLongSupplier
. The returnedLongBinaryOperator
will unwrap present value from theOptionalLong
if possible, or fall back to callingsource
if theOptionalLong
is empty.- Parameters:
-
source
-LongSupplier
to query for fallback value whenOptionalLong
is empty - Returns:
-
plain
LongBinaryOperator
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-