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 ofIntBinaryOperatorthat returnsOptionalIntinstead of the raw value.OptionalIntBinaryOperatoris typically obtained fromExceptionHandler.fromIntBinaryOperator(IntBinaryOperator), in which case its return value is empty when the underlyingIntBinaryOperatorthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalIntapply(int left, int right)Variation ofIntBinaryOperator.applyAsInt(int, int)that returnsOptionalInt.default IntBinaryOperatororElse(int result)Converts thisOptionalIntBinaryOperatorto plainIntBinaryOperatorusing default value.default IntBinaryOperatororElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(int left, int right)
Variation ofIntBinaryOperator.applyAsInt(int, int)that returnsOptionalInt. If thisOptionalIntBinaryOperatoris obtained fromExceptionHandler.fromIntBinaryOperator(IntBinaryOperator), theOptionalIntwill be empty only if the underlyingIntBinaryOperatorthrows. Otherwise the returnedOptionalIntjust wraps the return value of underlyingIntBinaryOperator.- Parameters:
-
left- seeIntBinaryOperator.applyAsInt(int, int) -
right- seeIntBinaryOperator.applyAsInt(int, int) - Returns:
-
OptionalInttypically 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 thisOptionalIntBinaryOperatorto plainIntBinaryOperatorusing default value. The returnedIntBinaryOperatorwill unwrap present value from theOptionalIntif possible, or returnresultif theOptionalIntis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalInt - Returns:
-
plain
IntBinaryOperatorthat either unwrapsOptionalIntor returns default value - See Also:
-
orElseGet(IntSupplier),OptionalInt.orElse(int)
-
orElseGet
default IntBinaryOperator orElseGet(IntSupplier source)
Converts thisOptionalIntBinaryOperatorto plainIntBinaryOperatorusing fallbackIntSupplier. The returnedIntBinaryOperatorwill unwrap present value from theOptionalIntif possible, or fall back to callingsourceif theOptionalIntis empty.- Parameters:
-
source-IntSupplierto query for fallback value whenOptionalIntis empty - Returns:
-
plain
IntBinaryOperatorthat either unwrapsOptionalIntor falls back tosource - See Also:
-
orElse(int),OptionalInt.orElseGet(IntSupplier)
-
-