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