Module com.machinezoo.noexception
Interface OptionalDoubleToIntFunction
-
- All Superinterfaces:
-
DoubleFunction<OptionalInt>
- 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 OptionalDoubleToIntFunction extends DoubleFunction<OptionalInt>
Variation ofDoubleToIntFunctionthat returnsOptionalIntinstead of the raw value.OptionalDoubleToIntFunctionis typically obtained fromExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction), in which case its return value is empty when the underlyingDoubleToIntFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalIntapply(double value)Variation ofDoubleToIntFunction.applyAsInt(double)that returnsOptionalInt.default DoubleToIntFunctionorElse(int result)Converts thisOptionalDoubleToIntFunctionto plainDoubleToIntFunctionusing default value.default DoubleToIntFunctionorElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(double value)
Variation ofDoubleToIntFunction.applyAsInt(double)that returnsOptionalInt. If thisOptionalDoubleToIntFunctionis obtained fromExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction), theOptionalIntwill be empty only if the underlyingDoubleToIntFunctionthrows. Otherwise the returnedOptionalIntjust wraps the return value of underlyingDoubleToIntFunction.- Specified by:
-
applyin interfaceDoubleFunction<OptionalInt> - Parameters:
-
value- seeDoubleToIntFunction.applyAsInt(double) - Returns:
-
OptionalInttypically wrapping return value ofDoubleToIntFunction.applyAsInt(double), or an emptyOptionalInt(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction),DoubleToIntFunction.applyAsInt(double)
-
orElse
default DoubleToIntFunction orElse(int result)
Converts thisOptionalDoubleToIntFunctionto plainDoubleToIntFunctionusing default value. The returnedDoubleToIntFunctionwill unwrap present value from theOptionalIntif possible, or returnresultif theOptionalIntis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalInt - Returns:
-
plain
DoubleToIntFunctionthat either unwrapsOptionalIntor returns default value - See Also:
-
orElseGet(IntSupplier),OptionalInt.orElse(int)
-
orElseGet
default DoubleToIntFunction orElseGet(IntSupplier source)
Converts thisOptionalDoubleToIntFunctionto plainDoubleToIntFunctionusing fallbackIntSupplier. The returnedDoubleToIntFunctionwill unwrap present value from theOptionalIntif possible, or fall back to callingsourceif theOptionalIntis empty.- Parameters:
-
source-IntSupplierto query for fallback value whenOptionalIntis empty - Returns:
-
plain
DoubleToIntFunctionthat either unwrapsOptionalIntor falls back tosource - See Also:
-
orElse(int),OptionalInt.orElseGet(IntSupplier)
-
-