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 ofLongBinaryOperatorthat returnsOptionalLonginstead of the raw value.OptionalLongBinaryOperatoris typically obtained fromExceptionHandler.fromLongBinaryOperator(LongBinaryOperator), in which case its return value is empty when the underlyingLongBinaryOperatorthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLongapply(long left, long right)Variation ofLongBinaryOperator.applyAsLong(long, long)that returnsOptionalLong.default LongBinaryOperatororElse(long result)Converts thisOptionalLongBinaryOperatorto plainLongBinaryOperatorusing default value.default LongBinaryOperatororElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(long left, long right)
Variation ofLongBinaryOperator.applyAsLong(long, long)that returnsOptionalLong. If thisOptionalLongBinaryOperatoris obtained fromExceptionHandler.fromLongBinaryOperator(LongBinaryOperator), theOptionalLongwill be empty only if the underlyingLongBinaryOperatorthrows. Otherwise the returnedOptionalLongjust wraps the return value of underlyingLongBinaryOperator.- Parameters:
-
left- seeLongBinaryOperator.applyAsLong(long, long) -
right- seeLongBinaryOperator.applyAsLong(long, long) - Returns:
-
OptionalLongtypically 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 thisOptionalLongBinaryOperatorto plainLongBinaryOperatorusing default value. The returnedLongBinaryOperatorwill unwrap present value from theOptionalLongif possible, or returnresultif theOptionalLongis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalLong - Returns:
-
plain
LongBinaryOperatorthat either unwrapsOptionalLongor returns default value - See Also:
-
orElseGet(LongSupplier),OptionalLong.orElse(long)
-
orElseGet
default LongBinaryOperator orElseGet(LongSupplier source)
Converts thisOptionalLongBinaryOperatorto plainLongBinaryOperatorusing fallbackLongSupplier. The returnedLongBinaryOperatorwill unwrap present value from theOptionalLongif possible, or fall back to callingsourceif theOptionalLongis empty.- Parameters:
-
source-LongSupplierto query for fallback value whenOptionalLongis empty - Returns:
-
plain
LongBinaryOperatorthat either unwrapsOptionalLongor falls back tosource - See Also:
-
orElse(long),OptionalLong.orElseGet(LongSupplier)
-
-