Module com.machinezoo.noexception
Interface OptionalToLongFunction<T>
-
- Type Parameters:
-
T- seeToLongFunction
- All Superinterfaces:
-
Function<T,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 OptionalToLongFunction<T> extends Function<T,OptionalLong>
Variation ofToLongFunctionthat returnsOptionalLonginstead of the raw value.OptionalToLongFunctionis typically obtained fromExceptionHandler.fromToLongFunction(ToLongFunction), in which case its return value is empty when the underlyingToLongFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLongapply(T value)Variation ofToLongFunction.applyAsLong(Object)that returnsOptionalLong.default ToLongFunction<T>orElse(long result)Converts thisOptionalToLongFunctionto plainToLongFunctionusing default value.default ToLongFunction<T>orElseGet(LongSupplier source)
-
-
-
Method Detail
-
apply
OptionalLong apply(T value)
Variation ofToLongFunction.applyAsLong(Object)that returnsOptionalLong. If thisOptionalToLongFunctionis obtained fromExceptionHandler.fromToLongFunction(ToLongFunction), theOptionalLongwill be empty only if the underlyingToLongFunctionthrows. Otherwise the returnedOptionalLongjust wraps the return value of underlyingToLongFunction.- Specified by:
-
applyin interfaceFunction<T,OptionalLong> - Parameters:
-
value- seeToLongFunction.applyAsLong(Object) - Returns:
-
OptionalLongtypically wrapping return value ofToLongFunction.applyAsLong(Object), or an emptyOptionalLong(typically signifying an exception) - See Also:
-
ExceptionHandler.fromToLongFunction(ToLongFunction),ToLongFunction.applyAsLong(Object)
-
orElse
default ToLongFunction<T> orElse(long result)
Converts thisOptionalToLongFunctionto plainToLongFunctionusing default value. The returnedToLongFunctionwill unwrap present value from theOptionalLongif possible, or returnresultif theOptionalLongis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalLong - Returns:
-
plain
ToLongFunctionthat either unwrapsOptionalLongor returns default value - See Also:
-
orElseGet(LongSupplier),OptionalLong.orElse(long)
-
orElseGet
default ToLongFunction<T> orElseGet(LongSupplier source)
Converts thisOptionalToLongFunctionto plainToLongFunctionusing fallbackLongSupplier. The returnedToLongFunctionwill unwrap present value from theOptionalLongif possible, or fall back to callingsourceif theOptionalLongis empty.- Parameters:
-
source-LongSupplierto query for fallback value whenOptionalLongis empty - Returns:
-
plain
ToLongFunctionthat either unwrapsOptionalLongor falls back tosource - See Also:
-
orElse(long),OptionalLong.orElseGet(LongSupplier)
-
-