Module com.machinezoo.noexception
Interface OptionalBiFunction<T,U,R>
-
- Type Parameters:
-
T- seeBiFunction -
U- seeBiFunction -
R- seeBiFunction
- All Superinterfaces:
-
BiFunction<T,U,Optional<R>>
- 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 OptionalBiFunction<T,U,R> extends BiFunction<T,U,Optional<R>>
Variation ofBiFunctionthat returnsOptionalinstead of the raw value.OptionalBiFunctionis typically obtained fromExceptionHandler.fromBiFunction(BiFunction), in which case its return value is empty when the underlyingBiFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<R>apply(T t, U u)Variation ofBiFunction.apply(Object, Object)that returnsOptional.default BiFunction<T,U,R>orElse(R result)Converts thisOptionalBiFunctionto plainBiFunctionusing default value.default BiFunction<T,U,R>orElseGet(Supplier<R> source)-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
Optional<R> apply(T t, U u)
Variation ofBiFunction.apply(Object, Object)that returnsOptional. If thisOptionalBiFunctionis obtained fromExceptionHandler.fromBiFunction(BiFunction), theOptionalwill be empty only if the underlyingBiFunctionthrows. Otherwise the returnedOptionaljust wraps the return value of underlyingBiFunction(possiblynull).- Specified by:
-
applyin interfaceBiFunction<T,U,R> - Parameters:
-
t- seeBiFunction.apply(Object, Object) -
u- seeBiFunction.apply(Object, Object) - Returns:
-
Optionaltypically wrapping return value ofBiFunction.apply(Object, Object), or an emptyOptional(typically signifying an exception) - See Also:
-
ExceptionHandler.fromBiFunction(BiFunction),BiFunction.apply(Object, Object)
-
orElse
default BiFunction<T,U,R> orElse(R result)
Converts thisOptionalBiFunctionto plainBiFunctionusing default value. The returnedBiFunctionwill unwrap present value from theOptionalif possible, or returnresultif theOptionalis empty.- Parameters:
-
result- default value to return instead of an emptyOptional - Returns:
-
plain
BiFunctionthat either unwrapsOptionalor returns default value - See Also:
-
orElseGet(Supplier),Optional.orElse(Object)
-
orElseGet
default BiFunction<T,U,R> orElseGet(Supplier<R> source)
Converts thisOptionalBiFunctionto plainBiFunctionusing fallbackSupplier. The returnedBiFunctionwill unwrap present value from theOptionalif possible, or fall back to callingsourceif theOptionalis empty.- Parameters:
-
source-Supplierto query for fallback value whenOptionalis empty - Returns:
-
plain
BiFunctionthat either unwrapsOptionalor falls back tosource - See Also:
-
orElse(Object),Optional.orElseGet(Supplier)
-
-