Module com.machinezoo.noexception
Interface OptionalLongToIntFunction
-
- All Superinterfaces:
-
LongFunction<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 OptionalLongToIntFunction extends LongFunction<OptionalInt>
Variation ofLongToIntFunctionthat returnsOptionalIntinstead of the raw value.OptionalLongToIntFunctionis typically obtained fromExceptionHandler.fromLongToIntFunction(LongToIntFunction), in which case its return value is empty when the underlyingLongToIntFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalIntapply(long value)Variation ofLongToIntFunction.applyAsInt(long)that returnsOptionalInt.default LongToIntFunctionorElse(int result)Converts thisOptionalLongToIntFunctionto plainLongToIntFunctionusing default value.default LongToIntFunctionorElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(long value)
Variation ofLongToIntFunction.applyAsInt(long)that returnsOptionalInt. If thisOptionalLongToIntFunctionis obtained fromExceptionHandler.fromLongToIntFunction(LongToIntFunction), theOptionalIntwill be empty only if the underlyingLongToIntFunctionthrows. Otherwise the returnedOptionalIntjust wraps the return value of underlyingLongToIntFunction.- Specified by:
-
applyin interfaceLongFunction<OptionalInt> - Parameters:
-
value- seeLongToIntFunction.applyAsInt(long) - Returns:
-
OptionalInttypically wrapping return value ofLongToIntFunction.applyAsInt(long), or an emptyOptionalInt(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongToIntFunction(LongToIntFunction),LongToIntFunction.applyAsInt(long)
-
orElse
default LongToIntFunction orElse(int result)
Converts thisOptionalLongToIntFunctionto plainLongToIntFunctionusing default value. The returnedLongToIntFunctionwill unwrap present value from theOptionalIntif possible, or returnresultif theOptionalIntis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalInt - Returns:
-
plain
LongToIntFunctionthat either unwrapsOptionalIntor returns default value - See Also:
-
orElseGet(IntSupplier),OptionalInt.orElse(int)
-
orElseGet
default LongToIntFunction orElseGet(IntSupplier source)
Converts thisOptionalLongToIntFunctionto plainLongToIntFunctionusing fallbackIntSupplier. The returnedLongToIntFunctionwill unwrap present value from theOptionalIntif possible, or fall back to callingsourceif theOptionalIntis empty.- Parameters:
-
source-IntSupplierto query for fallback value whenOptionalIntis empty - Returns:
-
plain
LongToIntFunctionthat either unwrapsOptionalIntor falls back tosource - See Also:
-
orElse(int),OptionalInt.orElseGet(IntSupplier)
-
-