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 ofLongSupplierthat returnsOptionalLonginstead of the raw value.OptionalLongSupplieris typically obtained fromExceptionHandler.fromLongSupplier(LongSupplier), in which case its return value is empty when the underlyingLongSupplierthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLongget()Variation ofLongSupplier.getAsLong()that returnsOptionalLong.default LongSupplierorElse(long result)Converts thisOptionalLongSupplierto plainLongSupplierusing default value.default LongSupplierorElseGet(LongSupplier source)
-
-
-
Method Detail
-
get
OptionalLong get()
Variation ofLongSupplier.getAsLong()that returnsOptionalLong. If thisOptionalLongSupplieris obtained fromExceptionHandler.fromLongSupplier(LongSupplier), theOptionalLongwill be empty only if the underlyingLongSupplierthrows. Otherwise the returnedOptionalLongjust wraps the return value of underlyingLongSupplier.- Specified by:
-
getin interfaceSupplier<OptionalLong> - Returns:
-
OptionalLongtypically 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 thisOptionalLongSupplierto plainLongSupplierusing default value. The returnedLongSupplierwill unwrap present value from theOptionalLongif possible, or returnresultif theOptionalLongis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalLong - Returns:
-
plain
LongSupplierthat either unwrapsOptionalLongor returns default value - See Also:
-
orElseGet(LongSupplier),OptionalLong.orElse(long)
-
orElseGet
default LongSupplier orElseGet(LongSupplier source)
Converts thisOptionalLongSupplierto plainLongSupplierusing fallbackLongSupplier. The returnedLongSupplierwill unwrap present value from theOptionalLongif possible, or fall back to callingsourceif theOptionalLongis empty.- Parameters:
-
source-LongSupplierto query for fallback value whenOptionalLongis empty - Returns:
-
plain
LongSupplierthat either unwrapsOptionalLongor falls back tosource - See Also:
-
orElse(long),OptionalLong.orElseGet(LongSupplier)
-
-