Module com.machinezoo.noexception
Interface OptionalLongUnaryOperator
-
- All Superinterfaces:
-
LongFunction<OptionalLong>
- 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 OptionalLongUnaryOperator extends LongFunction<OptionalLong>
Variation ofLongUnaryOperatorthat returnsOptionalLonginstead of the raw value.OptionalLongUnaryOperatoris typically obtained fromExceptionHandler.fromLongUnaryOperator(LongUnaryOperator), in which case its return value is empty when the underlyingLongUnaryOperatorthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLongapply(long operand)Variation ofLongUnaryOperator.applyAsLong(long)that returnsOptionalLong.default LongUnaryOperatororElse(long result)Converts thisOptionalLongUnaryOperatorto plainLongUnaryOperatorusing default value.default LongUnaryOperatororElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(long operand)
Variation ofLongUnaryOperator.applyAsLong(long)that returnsOptionalLong. If thisOptionalLongUnaryOperatoris obtained fromExceptionHandler.fromLongUnaryOperator(LongUnaryOperator), theOptionalLongwill be empty only if the underlyingLongUnaryOperatorthrows. Otherwise the returnedOptionalLongjust wraps the return value of underlyingLongUnaryOperator.- Specified by:
-
applyin interfaceLongFunction<OptionalLong> - Parameters:
-
operand- seeLongUnaryOperator.applyAsLong(long) - Returns:
-
OptionalLongtypically wrapping return value ofLongUnaryOperator.applyAsLong(long), or an emptyOptionalLong(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongUnaryOperator(LongUnaryOperator),LongUnaryOperator.applyAsLong(long)
-
orElse
default LongUnaryOperator orElse(long result)
Converts thisOptionalLongUnaryOperatorto plainLongUnaryOperatorusing default value. The returnedLongUnaryOperatorwill unwrap present value from theOptionalLongif possible, or returnresultif theOptionalLongis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalLong - Returns:
-
plain
LongUnaryOperatorthat either unwrapsOptionalLongor returns default value - See Also:
-
orElseGet(LongSupplier),OptionalLong.orElse(long)
-
orElseGet
default LongUnaryOperator orElseGet(LongSupplier source)
Converts thisOptionalLongUnaryOperatorto plainLongUnaryOperatorusing fallbackLongSupplier. The returnedLongUnaryOperatorwill unwrap present value from theOptionalLongif possible, or fall back to callingsourceif theOptionalLongis empty.- Parameters:
-
source-LongSupplierto query for fallback value whenOptionalLongis empty - Returns:
-
plain
LongUnaryOperatorthat either unwrapsOptionalLongor falls back tosource - See Also:
-
orElse(long),OptionalLong.orElseGet(LongSupplier)
-
-