Module com.machinezoo.noexception
Interface OptionalLongSupplier
-
- All Superinterfaces:
-
Supplier<OptionalLong>
- 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 OptionalLongSupplier extends Supplier<OptionalLong>
Variation ofLongSupplier
that returnsOptionalLong
instead of the raw value.OptionalLongSupplier
is typically obtained fromExceptionHandler.fromLongSupplier(LongSupplier)
, in which case its return value is empty when the underlyingLongSupplier
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
get()
Variation ofLongSupplier.getAsLong()
that returnsOptionalLong
.default LongSupplier
orElse(long result)
Converts thisOptionalLongSupplier
to plainLongSupplier
using default value.default LongSupplier
orElseGet(LongSupplier source)
-
-
-
Method Detail
-
get
OptionalLong get()
Variation ofLongSupplier.getAsLong()
that returnsOptionalLong
. If thisOptionalLongSupplier
is obtained fromExceptionHandler.fromLongSupplier(LongSupplier)
, theOptionalLong
will be empty only if the underlyingLongSupplier
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingLongSupplier
.- Specified by:
-
get
in interfaceSupplier<OptionalLong>
- Returns:
-
OptionalLong
typically wrapping return value ofLongSupplier.getAsLong()
, or an emptyOptionalLong
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongSupplier(LongSupplier)
,LongSupplier.getAsLong()
-
orElse
default LongSupplier orElse(long result)
Converts thisOptionalLongSupplier
to plainLongSupplier
using default value. The returnedLongSupplier
will unwrap present value from theOptionalLong
if possible, or returnresult
if theOptionalLong
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalLong
- Returns:
-
plain
LongSupplier
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default LongSupplier orElseGet(LongSupplier source)
Converts thisOptionalLongSupplier
to plainLongSupplier
using fallbackLongSupplier
. The returnedLongSupplier
will unwrap present value from theOptionalLong
if possible, or fall back to callingsource
if theOptionalLong
is empty.- Parameters:
-
source
-LongSupplier
to query for fallback value whenOptionalLong
is empty - Returns:
-
plain
LongSupplier
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-