Module com.machinezoo.noexception
Interface OptionalLongToIntFunction
-
- All Superinterfaces:
-
LongFunction<OptionalInt>
- 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 OptionalLongToIntFunction extends LongFunction<OptionalInt>
Variation ofLongToIntFunction
that returnsOptionalInt
instead of the raw value.OptionalLongToIntFunction
is typically obtained fromExceptionHandler.fromLongToIntFunction(LongToIntFunction)
, in which case its return value is empty when the underlyingLongToIntFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalInt
apply(long value)
Variation ofLongToIntFunction.applyAsInt(long)
that returnsOptionalInt
.default LongToIntFunction
orElse(int result)
Converts thisOptionalLongToIntFunction
to plainLongToIntFunction
using default value.default LongToIntFunction
orElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(long value)
Variation ofLongToIntFunction.applyAsInt(long)
that returnsOptionalInt
. If thisOptionalLongToIntFunction
is obtained fromExceptionHandler.fromLongToIntFunction(LongToIntFunction)
, theOptionalInt
will be empty only if the underlyingLongToIntFunction
throws. Otherwise the returnedOptionalInt
just wraps the return value of underlyingLongToIntFunction
.- Specified by:
-
apply
in interfaceLongFunction<OptionalInt>
- Parameters:
-
value
- seeLongToIntFunction.applyAsInt(long)
- Returns:
-
OptionalInt
typically wrapping return value ofLongToIntFunction.applyAsInt(long)
, or an emptyOptionalInt
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongToIntFunction(LongToIntFunction)
,LongToIntFunction.applyAsInt(long)
-
orElse
default LongToIntFunction orElse(int result)
Converts thisOptionalLongToIntFunction
to plainLongToIntFunction
using default value. The returnedLongToIntFunction
will unwrap present value from theOptionalInt
if possible, or returnresult
if theOptionalInt
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalInt
- Returns:
-
plain
LongToIntFunction
that either unwrapsOptionalInt
or returns default value - See Also:
-
orElseGet(IntSupplier)
,OptionalInt.orElse(int)
-
orElseGet
default LongToIntFunction orElseGet(IntSupplier source)
Converts thisOptionalLongToIntFunction
to plainLongToIntFunction
using fallbackIntSupplier
. The returnedLongToIntFunction
will unwrap present value from theOptionalInt
if possible, or fall back to callingsource
if theOptionalInt
is empty.- Parameters:
-
source
-IntSupplier
to query for fallback value whenOptionalInt
is empty - Returns:
-
plain
LongToIntFunction
that either unwrapsOptionalInt
or falls back tosource
- See Also:
-
orElse(int)
,OptionalInt.orElseGet(IntSupplier)
-
-