Module com.machinezoo.noexception
Interface OptionalLongToDoubleFunction
-
- All Superinterfaces:
-
LongFunction<OptionalDouble>
- 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 OptionalLongToDoubleFunction extends LongFunction<OptionalDouble>
Variation ofLongToDoubleFunctionthat returnsOptionalDoubleinstead of the raw value.OptionalLongToDoubleFunctionis typically obtained fromExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction), in which case its return value is empty when the underlyingLongToDoubleFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDoubleapply(long value)Variation ofLongToDoubleFunction.applyAsDouble(long)that returnsOptionalDouble.default LongToDoubleFunctionorElse(double result)Converts thisOptionalLongToDoubleFunctionto plainLongToDoubleFunctionusing default value.default LongToDoubleFunctionorElseGet(DoubleSupplier source)Converts thisOptionalLongToDoubleFunctionto plainLongToDoubleFunctionusing fallbackDoubleSupplier.
-
-
-
Method Detail
-
apply
OptionalDouble apply(long value)
Variation ofLongToDoubleFunction.applyAsDouble(long)that returnsOptionalDouble. If thisOptionalLongToDoubleFunctionis obtained fromExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction), theOptionalDoublewill be empty only if the underlyingLongToDoubleFunctionthrows. Otherwise the returnedOptionalDoublejust wraps the return value of underlyingLongToDoubleFunction.- Specified by:
-
applyin interfaceLongFunction<OptionalDouble> - Parameters:
-
value- seeLongToDoubleFunction.applyAsDouble(long) - Returns:
-
OptionalDoubletypically wrapping return value ofLongToDoubleFunction.applyAsDouble(long), or an emptyOptionalDouble(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction),LongToDoubleFunction.applyAsDouble(long)
-
orElse
default LongToDoubleFunction orElse(double result)
Converts thisOptionalLongToDoubleFunctionto plainLongToDoubleFunctionusing default value. The returnedLongToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or returnresultif theOptionalDoubleis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalDouble - Returns:
-
plain
LongToDoubleFunctionthat either unwrapsOptionalDoubleor returns default value - See Also:
-
orElseGet(DoubleSupplier),OptionalDouble.orElse(double)
-
orElseGet
default LongToDoubleFunction orElseGet(DoubleSupplier source)
Converts thisOptionalLongToDoubleFunctionto plainLongToDoubleFunctionusing fallbackDoubleSupplier. The returnedLongToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or fall back to callingsourceif theOptionalDoubleis empty.- Parameters:
-
source-DoubleSupplierto query for fallback value whenOptionalDoubleis empty - Returns:
-
plain
LongToDoubleFunctionthat either unwrapsOptionalDoubleor falls back tosource - See Also:
-
orElse(double),OptionalDouble.orElseGet(DoubleSupplier)
-
-