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 ofLongUnaryOperator
that returnsOptionalLong
instead of the raw value.OptionalLongUnaryOperator
is typically obtained fromExceptionHandler.fromLongUnaryOperator(LongUnaryOperator)
, in which case its return value is empty when the underlyingLongUnaryOperator
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
apply(long operand)
Variation ofLongUnaryOperator.applyAsLong(long)
that returnsOptionalLong
.default LongUnaryOperator
orElse(long result)
Converts thisOptionalLongUnaryOperator
to plainLongUnaryOperator
using default value.default LongUnaryOperator
orElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(long operand)
Variation ofLongUnaryOperator.applyAsLong(long)
that returnsOptionalLong
. If thisOptionalLongUnaryOperator
is obtained fromExceptionHandler.fromLongUnaryOperator(LongUnaryOperator)
, theOptionalLong
will be empty only if the underlyingLongUnaryOperator
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingLongUnaryOperator
.- Specified by:
-
apply
in interfaceLongFunction<OptionalLong>
- Parameters:
-
operand
- seeLongUnaryOperator.applyAsLong(long)
- Returns:
-
OptionalLong
typically 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 thisOptionalLongUnaryOperator
to plainLongUnaryOperator
using default value. The returnedLongUnaryOperator
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
LongUnaryOperator
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default LongUnaryOperator orElseGet(LongSupplier source)
Converts thisOptionalLongUnaryOperator
to plainLongUnaryOperator
using fallbackLongSupplier
. The returnedLongUnaryOperator
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
LongUnaryOperator
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-