There's a default method andThen()
in the BiFunction
interface (java.util.function
package).
default <V> BiFunction<T,U,V> andThen(Function<? super R,? extends V> after)
The documentation says:
Returns a composed function that first applies this function to its input, and then applies the after function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.
It's little confusing to understand what the explanation means. As per my understanding, a composed function is returned when the default andThen()
method is invoked. This composed function is invoked on the types T
and U
that returns the type V
. Finally, there's and after
function that is invoked on the types R
and V
.
What's the need of this method? How does it actually fit in the picture?