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 ofToIntBiFunction
that returnsOptionalInt
instead of the raw value.OptionalToIntBiFunction
is typically obtained fromExceptionHandler.fromToIntBiFunction(ToIntBiFunction)
, in which case its return value is empty when the underlyingToIntBiFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalInt
apply(T t, U u)
Variation ofToIntBiFunction.applyAsInt(Object, Object)
that returnsOptionalInt
.default ToIntBiFunction<T,U>
orElse(int result)
Converts thisOptionalToIntBiFunction
to plainToIntBiFunction
using 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 thisOptionalToIntBiFunction
is obtained fromExceptionHandler.fromToIntBiFunction(ToIntBiFunction)
, theOptionalInt
will be empty only if the underlyingToIntBiFunction
throws. Otherwise the returnedOptionalInt
just wraps the return value of underlyingToIntBiFunction
.- Specified by:
-
apply
in interfaceBiFunction<T,U,OptionalInt>
- Parameters:
-
t
- seeToIntBiFunction.applyAsInt(Object, Object)
-
u
- seeToIntBiFunction.applyAsInt(Object, Object)
- Returns:
-
OptionalInt
typically 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 thisOptionalToIntBiFunction
to plainToIntBiFunction
using default value. The returnedToIntBiFunction
will unwrap present value from theOptionalInt
if possible, or returnresult
if theOptionalInt
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalInt
- Returns:
-
plain
ToIntBiFunction
that either unwrapsOptionalInt
or returns default value - See Also:
-
orElseGet(IntSupplier)
,OptionalInt.orElse(int)
-
orElseGet
default ToIntBiFunction<T,U> orElseGet(IntSupplier source)
Converts thisOptionalToIntBiFunction
to plainToIntBiFunction
using fallbackIntSupplier
. The returnedToIntBiFunction
will unwrap present value from theOptionalInt
if possible, or fall back to callingsource
if theOptionalInt
is empty.- Parameters:
-
source
-IntSupplier
to query for fallback value whenOptionalInt
is empty - Returns:
-
plain
ToIntBiFunction
that either unwrapsOptionalInt
or falls back tosource
- See Also:
-
orElse(int)
,OptionalInt.orElseGet(IntSupplier)
-
-