Module com.machinezoo.noexception
Interface OptionalIntUnaryOperator
-
- All Superinterfaces:
-
IntFunction<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 OptionalIntUnaryOperator extends IntFunction<OptionalInt>
Variation ofIntUnaryOperatorthat returnsOptionalIntinstead of the raw value.OptionalIntUnaryOperatoris typically obtained fromExceptionHandler.fromIntUnaryOperator(IntUnaryOperator), in which case its return value is empty when the underlyingIntUnaryOperatorthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalIntapply(int operand)Variation ofIntUnaryOperator.applyAsInt(int)that returnsOptionalInt.default IntUnaryOperatororElse(int result)Converts thisOptionalIntUnaryOperatorto plainIntUnaryOperatorusing default value.default IntUnaryOperatororElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(int operand)
Variation ofIntUnaryOperator.applyAsInt(int)that returnsOptionalInt. If thisOptionalIntUnaryOperatoris obtained fromExceptionHandler.fromIntUnaryOperator(IntUnaryOperator), theOptionalIntwill be empty only if the underlyingIntUnaryOperatorthrows. Otherwise the returnedOptionalIntjust wraps the return value of underlyingIntUnaryOperator.- Specified by:
-
applyin interfaceIntFunction<OptionalInt> - Parameters:
-
operand- seeIntUnaryOperator.applyAsInt(int) - Returns:
-
OptionalInttypically wrapping return value ofIntUnaryOperator.applyAsInt(int), or an emptyOptionalInt(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntUnaryOperator(IntUnaryOperator),IntUnaryOperator.applyAsInt(int)
-
orElse
default IntUnaryOperator orElse(int result)
Converts thisOptionalIntUnaryOperatorto plainIntUnaryOperatorusing default value. The returnedIntUnaryOperatorwill unwrap present value from theOptionalIntif possible, or returnresultif theOptionalIntis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalInt - Returns:
-
plain
IntUnaryOperatorthat either unwrapsOptionalIntor returns default value - See Also:
-
orElseGet(IntSupplier),OptionalInt.orElse(int)
-
orElseGet
default IntUnaryOperator orElseGet(IntSupplier source)
Converts thisOptionalIntUnaryOperatorto plainIntUnaryOperatorusing fallbackIntSupplier. The returnedIntUnaryOperatorwill unwrap present value from theOptionalIntif possible, or fall back to callingsourceif theOptionalIntis empty.- Parameters:
-
source-IntSupplierto query for fallback value whenOptionalIntis empty - Returns:
-
plain
IntUnaryOperatorthat either unwrapsOptionalIntor falls back tosource - See Also:
-
orElse(int),OptionalInt.orElseGet(IntSupplier)
-
-