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 ofBooleanSupplierthat returnsOptionalBooleaninstead of the raw value.OptionalBooleanSupplieris typically obtained fromExceptionHandler.fromBooleanSupplier(BooleanSupplier), in which case its return value is empty when the underlyingBooleanSupplierthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalBooleanget()Variation ofBooleanSupplier.getAsBoolean()that returnsOptionalBoolean.default BooleanSupplierorElse(boolean result)Converts thisOptionalBooleanSupplierto plainBooleanSupplierusing default value.default BooleanSupplierorElseGet(BooleanSupplier source)
-
-
-
Method Detail
-
get
OptionalBoolean get()
Variation ofBooleanSupplier.getAsBoolean()that returnsOptionalBoolean. If thisOptionalBooleanSupplieris obtained fromExceptionHandler.fromBooleanSupplier(BooleanSupplier), theOptionalBooleanwill be empty only if the underlyingBooleanSupplierthrows. Otherwise the returnedOptionalBooleanjust wraps the return value of underlyingBooleanSupplier.- Specified by:
-
getin interfaceSupplier<OptionalBoolean> - Returns:
-
OptionalBooleantypically 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 thisOptionalBooleanSupplierto plainBooleanSupplierusing default value. The returnedBooleanSupplierwill unwrap present value from theOptionalBooleanif possible, or returnresultif theOptionalBooleanis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalBoolean - Returns:
-
plain
BooleanSupplierthat either unwrapsOptionalBooleanor returns default value - See Also:
-
orElseGet(BooleanSupplier),OptionalBoolean.orElse(boolean)
-
orElseGet
default BooleanSupplier orElseGet(BooleanSupplier source)
Converts thisOptionalBooleanSupplierto plainBooleanSupplierusing fallbackBooleanSupplier. The returnedBooleanSupplierwill unwrap present value from theOptionalBooleanif possible, or fall back to callingsourceif theOptionalBooleanis empty.- Parameters:
-
source-BooleanSupplierto query for fallback value whenOptionalBooleanis empty - Returns:
-
plain
BooleanSupplierthat either unwrapsOptionalBooleanor falls back tosource - See Also:
-
orElse(boolean),OptionalBoolean.orElseGet(BooleanSupplier)
-
-