Module com.machinezoo.noexception
Interface OptionalIntToLongFunction
-
- All Superinterfaces:
-
IntFunction<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 OptionalIntToLongFunction extends IntFunction<OptionalLong>
Variation ofIntToLongFunctionthat returnsOptionalLonginstead of the raw value.OptionalIntToLongFunctionis typically obtained fromExceptionHandler.fromIntToLongFunction(IntToLongFunction), in which case its return value is empty when the underlyingIntToLongFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLongapply(int value)Variation ofIntToLongFunction.applyAsLong(int)that returnsOptionalLong.default IntToLongFunctionorElse(long result)Converts thisOptionalIntToLongFunctionto plainIntToLongFunctionusing default value.default IntToLongFunctionorElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(int value)
Variation ofIntToLongFunction.applyAsLong(int)that returnsOptionalLong. If thisOptionalIntToLongFunctionis obtained fromExceptionHandler.fromIntToLongFunction(IntToLongFunction), theOptionalLongwill be empty only if the underlyingIntToLongFunctionthrows. Otherwise the returnedOptionalLongjust wraps the return value of underlyingIntToLongFunction.- Specified by:
-
applyin interfaceIntFunction<OptionalLong> - Parameters:
-
value- seeIntToLongFunction.applyAsLong(int) - Returns:
-
OptionalLongtypically wrapping return value ofIntToLongFunction.applyAsLong(int), or an emptyOptionalLong(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntToLongFunction(IntToLongFunction),IntToLongFunction.applyAsLong(int)
-
orElse
default IntToLongFunction orElse(long result)
Converts thisOptionalIntToLongFunctionto plainIntToLongFunctionusing default value. The returnedIntToLongFunctionwill unwrap present value from theOptionalLongif possible, or returnresultif theOptionalLongis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalLong - Returns:
-
plain
IntToLongFunctionthat either unwrapsOptionalLongor returns default value - See Also:
-
orElseGet(LongSupplier),OptionalLong.orElse(long)
-
orElseGet
default IntToLongFunction orElseGet(LongSupplier source)
Converts thisOptionalIntToLongFunctionto plainIntToLongFunctionusing fallbackLongSupplier. The returnedIntToLongFunctionwill unwrap present value from theOptionalLongif possible, or fall back to callingsourceif theOptionalLongis empty.- Parameters:
-
source-LongSupplierto query for fallback value whenOptionalLongis empty - Returns:
-
plain
IntToLongFunctionthat either unwrapsOptionalLongor falls back tosource - See Also:
-
orElse(long),OptionalLong.orElseGet(LongSupplier)
-
-