Module com.machinezoo.noexception
Interface OptionalToIntBiFunction<T,U>
-
- Type Parameters:
-
T- seeToIntBiFunction -
U- seeToIntBiFunction
- All Superinterfaces:
-
BiFunction<T,U,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 OptionalToIntBiFunction<T,U> extends BiFunction<T,U,OptionalInt>
Variation ofToIntBiFunctionthat returnsOptionalIntinstead of the raw value.OptionalToIntBiFunctionis typically obtained fromExceptionHandler.fromToIntBiFunction(ToIntBiFunction), in which case its return value is empty when the underlyingToIntBiFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalIntapply(T t, U u)Variation ofToIntBiFunction.applyAsInt(Object, Object)that returnsOptionalInt.default ToIntBiFunction<T,U>orElse(int result)Converts thisOptionalToIntBiFunctionto plainToIntBiFunctionusing default value.default ToIntBiFunction<T,U>orElseGet(IntSupplier source)-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
OptionalInt apply(T t, U u)
Variation ofToIntBiFunction.applyAsInt(Object, Object)that returnsOptionalInt. If thisOptionalToIntBiFunctionis obtained fromExceptionHandler.fromToIntBiFunction(ToIntBiFunction), theOptionalIntwill be empty only if the underlyingToIntBiFunctionthrows. Otherwise the returnedOptionalIntjust wraps the return value of underlyingToIntBiFunction.- Specified by:
-
applyin interfaceBiFunction<T,U,OptionalInt> - Parameters:
-
t- seeToIntBiFunction.applyAsInt(Object, Object) -
u- seeToIntBiFunction.applyAsInt(Object, Object) - Returns:
-
OptionalInttypically wrapping return value ofToIntBiFunction.applyAsInt(Object, Object), or an emptyOptionalInt(typically signifying an exception) - See Also:
-
ExceptionHandler.fromToIntBiFunction(ToIntBiFunction),ToIntBiFunction.applyAsInt(Object, Object)
-
orElse
default ToIntBiFunction<T,U> orElse(int result)
Converts thisOptionalToIntBiFunctionto plainToIntBiFunctionusing default value. The returnedToIntBiFunctionwill unwrap present value from theOptionalIntif possible, or returnresultif theOptionalIntis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalInt - Returns:
-
plain
ToIntBiFunctionthat either unwrapsOptionalIntor returns default value - See Also:
-
orElseGet(IntSupplier),OptionalInt.orElse(int)
-
orElseGet
default ToIntBiFunction<T,U> orElseGet(IntSupplier source)
Converts thisOptionalToIntBiFunctionto plainToIntBiFunctionusing fallbackIntSupplier. The returnedToIntBiFunctionwill unwrap present value from theOptionalIntif possible, or fall back to callingsourceif theOptionalIntis empty.- Parameters:
-
source-IntSupplierto query for fallback value whenOptionalIntis empty - Returns:
-
plain
ToIntBiFunctionthat either unwrapsOptionalIntor falls back tosource - See Also:
-
orElse(int),OptionalInt.orElseGet(IntSupplier)
-
-