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