@FunctionalInterface public interface OptionalLongToIntFunction extends LongFunction<OptionalInt>
LongToIntFunction
that returns OptionalInt
instead of the raw value. OptionalLongToIntFunction
is typically obtained from ExceptionHandler.fromLongToIntFunction(LongToIntFunction)
, in which case its return value is empty when the underlying LongToIntFunction
throws an exception. See noexception tutorial.
Modifier and Type | Method and Description |
---|---|
OptionalInt |
apply(long value)
Variation of LongToIntFunction.applyAsInt(long) that returns OptionalInt .
|
default LongToIntFunction |
orElse(int result)
Converts this OptionalLongToIntFunction to plain LongToIntFunction using default value.
|
default LongToIntFunction |
orElseGet(IntSupplier source)
|
OptionalInt apply(long value)
LongToIntFunction.applyAsInt(long)
that returns OptionalInt
. If this OptionalLongToIntFunction
is obtained from ExceptionHandler.fromLongToIntFunction(LongToIntFunction)
, the OptionalInt
will be empty only if the underlying LongToIntFunction
throws. Otherwise the returned OptionalInt
just wraps the return value of underlying LongToIntFunction
.
apply
in interface LongFunction<OptionalInt>
value
- see LongToIntFunction.applyAsInt(long)
OptionalInt
typically wrapping return value of LongToIntFunction.applyAsInt(long)
, or an empty OptionalInt
(typically signifying an exception)
ExceptionHandler.fromLongToIntFunction(LongToIntFunction)
, LongToIntFunction.applyAsInt(long)
default LongToIntFunction orElse(int result)
OptionalLongToIntFunction
to plain LongToIntFunction
using default value. The returned LongToIntFunction
will unwrap present value from the OptionalInt
if possible, or return result
if the OptionalInt
is empty.
result
- default value to return instead of an empty OptionalInt
LongToIntFunction
that either unwraps OptionalInt
or returns default value
orElseGet(IntSupplier)
, OptionalInt.orElse(int)
default LongToIntFunction orElseGet(IntSupplier source)
OptionalLongToIntFunction
to plain LongToIntFunction
using fallback IntSupplier
. The returned LongToIntFunction
will unwrap present value from the OptionalInt
if possible, or fall back to calling source
if the OptionalInt
is empty.
source
- IntSupplier
to query for fallback value when OptionalInt
is empty
LongToIntFunction
that either unwraps OptionalInt
or falls back to source
orElse(int)
, OptionalInt.orElseGet(IntSupplier)
Copyright © 2017–2020 Robert Važan. All rights reserved.