Module com.machinezoo.noexception
Interface OptionalIntToLongFunction
-
- All Superinterfaces:
-
IntFunction<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 OptionalIntToLongFunction extends IntFunction<OptionalLong>
Variation ofIntToLongFunction
that returnsOptionalLong
instead of the raw value.OptionalIntToLongFunction
is typically obtained fromExceptionHandler.fromIntToLongFunction(IntToLongFunction)
, in which case its return value is empty when the underlyingIntToLongFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
apply(int value)
Variation ofIntToLongFunction.applyAsLong(int)
that returnsOptionalLong
.default IntToLongFunction
orElse(long result)
Converts thisOptionalIntToLongFunction
to plainIntToLongFunction
using default value.default IntToLongFunction
orElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(int value)
Variation ofIntToLongFunction.applyAsLong(int)
that returnsOptionalLong
. If thisOptionalIntToLongFunction
is obtained fromExceptionHandler.fromIntToLongFunction(IntToLongFunction)
, theOptionalLong
will be empty only if the underlyingIntToLongFunction
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingIntToLongFunction
.- Specified by:
-
apply
in interfaceIntFunction<OptionalLong>
- Parameters:
-
value
- seeIntToLongFunction.applyAsLong(int)
- Returns:
-
OptionalLong
typically wrapping return value ofIntToLongFunction.applyAsLong(int)
, or an emptyOptionalLong
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntToLongFunction(IntToLongFunction)
,IntToLongFunction.applyAsLong(int)
-
orElse
default IntToLongFunction orElse(long result)
Converts thisOptionalIntToLongFunction
to plainIntToLongFunction
using default value. The returnedIntToLongFunction
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
IntToLongFunction
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default IntToLongFunction orElseGet(LongSupplier source)
Converts thisOptionalIntToLongFunction
to plainIntToLongFunction
using fallbackLongSupplier
. The returnedIntToLongFunction
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
IntToLongFunction
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-