T
- see BiFunction
U
- see BiFunction
R
- see BiFunction
@FunctionalInterface public interface OptionalBiFunction<T,U,R> extends BiFunction<T,U,Optional<R>>
BiFunction
that returns Optional
instead of the raw value. OptionalBiFunction
is typically obtained from ExceptionHandler.fromBiFunction(BiFunction)
, in which case its return value is empty when the underlying BiFunction
throws an exception. See noexception tutorial.
Modifier and Type | Method and Description |
---|---|
Optional<R> |
apply(T t, U u)
Variation of BiFunction.apply(Object, Object) that returns Optional .
|
default BiFunction<T,U,R> |
orElse(R result)
Converts this OptionalBiFunction to plain BiFunction using default value.
|
default BiFunction<T,U,R> |
orElseGet(Supplier<R> source)
|
andThen
Optional<R> apply(T t, U u)
BiFunction.apply(Object, Object)
that returns Optional
. If this OptionalBiFunction
is obtained from ExceptionHandler.fromBiFunction(BiFunction)
, the Optional
will be empty only if the underlying BiFunction
throws. Otherwise the returned Optional
just wraps the return value of underlying BiFunction
(possibly null
).
apply
in interface BiFunction<T,U,Optional<R>>
t
- see BiFunction.apply(Object, Object)
u
- see BiFunction.apply(Object, Object)
Optional
typically wrapping return value of BiFunction.apply(Object, Object)
, or an empty Optional
(typically signifying an exception)
ExceptionHandler.fromBiFunction(BiFunction)
, BiFunction.apply(Object, Object)
default BiFunction<T,U,R> orElse(R result)
OptionalBiFunction
to plain BiFunction
using default value. The returned BiFunction
will unwrap present value from the Optional
if possible, or return result
if the Optional
is empty.
result
- default value to return instead of an empty Optional
BiFunction
that either unwraps Optional
or returns default value
orElseGet(Supplier)
, Optional.orElse(Object)
default BiFunction<T,U,R> orElseGet(Supplier<R> source)
OptionalBiFunction
to plain BiFunction
using fallback Supplier
. The returned BiFunction
will unwrap present value from the Optional
if possible, or fall back to calling source
if the Optional
is empty.
source
- Supplier
to query for fallback value when Optional
is empty
BiFunction
that either unwraps Optional
or falls back to source
orElse(Object)
, Optional.orElseGet(Supplier)
Copyright © 2017–2020 Robert Važan. All rights reserved.