Module com.machinezoo.noexception
Interface OptionalBooleanSupplier
-
- All Superinterfaces:
-
Supplier<OptionalBoolean>
- 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 OptionalBooleanSupplier extends Supplier<OptionalBoolean>
Variation ofBooleanSupplier
that returnsOptionalBoolean
instead of the raw value.OptionalBooleanSupplier
is typically obtained fromExceptionHandler.fromBooleanSupplier(BooleanSupplier)
, in which case its return value is empty when the underlyingBooleanSupplier
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalBoolean
get()
Variation ofBooleanSupplier.getAsBoolean()
that returnsOptionalBoolean
.default BooleanSupplier
orElse(boolean result)
Converts thisOptionalBooleanSupplier
to plainBooleanSupplier
using default value.default BooleanSupplier
orElseGet(BooleanSupplier source)
-
-
-
Method Detail
-
get
OptionalBoolean get()
Variation ofBooleanSupplier.getAsBoolean()
that returnsOptionalBoolean
. If thisOptionalBooleanSupplier
is obtained fromExceptionHandler.fromBooleanSupplier(BooleanSupplier)
, theOptionalBoolean
will be empty only if the underlyingBooleanSupplier
throws. Otherwise the returnedOptionalBoolean
just wraps the return value of underlyingBooleanSupplier
.- Specified by:
-
get
in interfaceSupplier<OptionalBoolean>
- Returns:
-
OptionalBoolean
typically wrapping return value ofBooleanSupplier.getAsBoolean()
, or an emptyOptionalBoolean
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromBooleanSupplier(BooleanSupplier)
,BooleanSupplier.getAsBoolean()
-
orElse
default BooleanSupplier orElse(boolean result)
Converts thisOptionalBooleanSupplier
to plainBooleanSupplier
using default value. The returnedBooleanSupplier
will unwrap present value from theOptionalBoolean
if possible, or returnresult
if theOptionalBoolean
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalBoolean
- Returns:
-
plain
BooleanSupplier
that either unwrapsOptionalBoolean
or returns default value - See Also:
-
orElseGet(BooleanSupplier)
,OptionalBoolean.orElse(boolean)
-
orElseGet
default BooleanSupplier orElseGet(BooleanSupplier source)
Converts thisOptionalBooleanSupplier
to plainBooleanSupplier
using fallbackBooleanSupplier
. The returnedBooleanSupplier
will unwrap present value from theOptionalBoolean
if possible, or fall back to callingsource
if theOptionalBoolean
is empty.- Parameters:
-
source
-BooleanSupplier
to query for fallback value whenOptionalBoolean
is empty - Returns:
-
plain
BooleanSupplier
that either unwrapsOptionalBoolean
or falls back tosource
- See Also:
-
orElse(boolean)
,OptionalBoolean.orElseGet(BooleanSupplier)
-
-