Module com.machinezoo.noexception
Interface OptionalIntBinaryOperator
-
- 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 OptionalIntBinaryOperator
Variation ofIntBinaryOperator
that returnsOptionalInt
instead of the raw value.OptionalIntBinaryOperator
is typically obtained fromExceptionHandler.fromIntBinaryOperator(IntBinaryOperator)
, in which case its return value is empty when the underlyingIntBinaryOperator
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalInt
apply(int left, int right)
Variation ofIntBinaryOperator.applyAsInt(int, int)
that returnsOptionalInt
.default IntBinaryOperator
orElse(int result)
Converts thisOptionalIntBinaryOperator
to plainIntBinaryOperator
using default value.default IntBinaryOperator
orElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(int left, int right)
Variation ofIntBinaryOperator.applyAsInt(int, int)
that returnsOptionalInt
. If thisOptionalIntBinaryOperator
is obtained fromExceptionHandler.fromIntBinaryOperator(IntBinaryOperator)
, theOptionalInt
will be empty only if the underlyingIntBinaryOperator
throws. Otherwise the returnedOptionalInt
just wraps the return value of underlyingIntBinaryOperator
.- Parameters:
-
left
- seeIntBinaryOperator.applyAsInt(int, int)
-
right
- seeIntBinaryOperator.applyAsInt(int, int)
- Returns:
-
OptionalInt
typically wrapping return value ofIntBinaryOperator.applyAsInt(int, int)
, or an emptyOptionalInt
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntBinaryOperator(IntBinaryOperator)
,IntBinaryOperator.applyAsInt(int, int)
-
orElse
default IntBinaryOperator orElse(int result)
Converts thisOptionalIntBinaryOperator
to plainIntBinaryOperator
using default value. The returnedIntBinaryOperator
will unwrap present value from theOptionalInt
if possible, or returnresult
if theOptionalInt
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalInt
- Returns:
-
plain
IntBinaryOperator
that either unwrapsOptionalInt
or returns default value - See Also:
-
orElseGet(IntSupplier)
,OptionalInt.orElse(int)
-
orElseGet
default IntBinaryOperator orElseGet(IntSupplier source)
Converts thisOptionalIntBinaryOperator
to plainIntBinaryOperator
using fallbackIntSupplier
. The returnedIntBinaryOperator
will unwrap present value from theOptionalInt
if possible, or fall back to callingsource
if theOptionalInt
is empty.- Parameters:
-
source
-IntSupplier
to query for fallback value whenOptionalInt
is empty - Returns:
-
plain
IntBinaryOperator
that either unwrapsOptionalInt
or falls back tosource
- See Also:
-
orElse(int)
,OptionalInt.orElseGet(IntSupplier)
-
-