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