Module com.machinezoo.noexception
Interface OptionalToLongBiFunction<T,U>
-
- Type Parameters:
-
T
- seeToLongBiFunction
-
U
- seeToLongBiFunction
- All Superinterfaces:
-
BiFunction<T,U,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 OptionalToLongBiFunction<T,U> extends BiFunction<T,U,OptionalLong>
Variation ofToLongBiFunction
that returnsOptionalLong
instead of the raw value.OptionalToLongBiFunction
is typically obtained fromExceptionHandler.fromToLongBiFunction(ToLongBiFunction)
, in which case its return value is empty when the underlyingToLongBiFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
apply(T t, U u)
Variation ofToLongBiFunction.applyAsLong(Object, Object)
that returnsOptionalLong
.default ToLongBiFunction<T,U>
orElse(long result)
Converts thisOptionalToLongBiFunction
to plainToLongBiFunction
using default value.default ToLongBiFunction<T,U>
orElseGet(LongSupplier source)
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
OptionalLong apply(T t, U u)
Variation ofToLongBiFunction.applyAsLong(Object, Object)
that returnsOptionalLong
. If thisOptionalToLongBiFunction
is obtained fromExceptionHandler.fromToLongBiFunction(ToLongBiFunction)
, theOptionalLong
will be empty only if the underlyingToLongBiFunction
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingToLongBiFunction
.- Specified by:
-
apply
in interfaceBiFunction<T,U,OptionalLong>
- Parameters:
-
t
- seeToLongBiFunction.applyAsLong(Object, Object)
-
u
- seeToLongBiFunction.applyAsLong(Object, Object)
- Returns:
-
OptionalLong
typically wrapping return value ofToLongBiFunction.applyAsLong(Object, Object)
, or an emptyOptionalLong
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromToLongBiFunction(ToLongBiFunction)
,ToLongBiFunction.applyAsLong(Object, Object)
-
orElse
default ToLongBiFunction<T,U> orElse(long result)
Converts thisOptionalToLongBiFunction
to plainToLongBiFunction
using default value. The returnedToLongBiFunction
will unwrap present value from theOptionalLong
if possible, or returnresult
if theOptionalLong
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalLong
- Returns:
-
plain
ToLongBiFunction
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default ToLongBiFunction<T,U> orElseGet(LongSupplier source)
Converts thisOptionalToLongBiFunction
to plainToLongBiFunction
using fallbackLongSupplier
. The returnedToLongBiFunction
will unwrap present value from theOptionalLong
if possible, or fall back to callingsource
if theOptionalLong
is empty.- Parameters:
-
source
-LongSupplier
to query for fallback value whenOptionalLong
is empty - Returns:
-
plain
ToLongBiFunction
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-