Package com.identityworksllc.iiq.common
Interface Functions.FunctionWithError<A,B>
-
- All Superinterfaces:
Function<A,B>
- Enclosing class:
- Functions
public static interface Functions.FunctionWithError<A,B> extends Function<A,B>
An extension of Function that allows functional code to throw an exception.If used in a context not expecting this class, the error will be caught, logged, and re-thrown.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V> Functions.FunctionWithError<A,V>
andThen(Function<? super B,? extends V> after)
default B
apply(A a)
Handles the case where this object is used in a regular Stream API, which cannot handle errors.B
applyWithError(A object)
Implements a function transforming an object of type A to an object of type B.default <V> Functions.FunctionWithError<V,B>
compose(Function<? super V,? extends A> before)
Creates an error-friendly function composition that first translates from input type V to intermediate type A, then translates from A to B.
-
-
-
Method Detail
-
andThen
default <V> Functions.FunctionWithError<A,V> andThen(Function<? super B,? extends V> after)
-
apply
default B apply(A a)
Handles the case where this object is used in a regular Stream API, which cannot handle errors.Logs the error and throws a runtime exception.
-
applyWithError
B applyWithError(A object) throws Throwable
Implements a function transforming an object of type A to an object of type B.This function can throw an arbitrary error.
- Parameters:
object
- The input object- Returns:
- The output object
- Throws:
Throwable
- if any errors occur
-
compose
default <V> Functions.FunctionWithError<V,B> compose(Function<? super V,? extends A> before)
Creates an error-friendly function composition that first translates from input type V to intermediate type A, then translates from A to B.B = f2(f1(V))
-
-