Package org.fuchss.tools.lambda
Class LambdaConvert
java.lang.Object
org.fuchss.tools.lambda.LambdaConvert
A converter class to convert Functions/Consumers .. with
Exception
to
"normal" Functions/Consumers/..- Author:
- Dominik Fuchss
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <I1,
I2, O> BiFunction<I1, I2, O> wrap
(BiFunctionWithException<I1, I2, O> func, Consumer<Exception> handler) Wrap aBiFunctionWithException
to aBiFunction
.static <I> Consumer<I>
wrap
(ConsumerWithException<I> consumer, Consumer<Exception> handler) Wrap aConsumerWithException
to aConsumer
.static <I,
O> Function<I, O> wrap
(FunctionWithException<I, O> func, Consumer<Exception> handler) Wrap aFunctionWithException
to aFunction
.static <O> Supplier<O>
wrap
(SupplierWithException<O> supplier, Consumer<Exception> handler) Wrap aSupplierWithException
to aSupplier
.static VoidFunction
wrap
(VoidFunctionWithException func, Consumer<Exception> handler) Wrap aVoidFunctionWithException
to aVoidFunction
.
-
Field Details
-
NIL
This handler will do nothing. -
STACK_TRACE
This handler will print a stack trace.
-
-
Method Details
-
wrap
public static <I,O> Function<I,O> wrap(FunctionWithException<I, O> func, Consumer<Exception> handler) Wrap aFunctionWithException
to aFunction
.- Type Parameters:
I
- the input typeO
- the output type- Parameters:
func
- the functionhandler
- the exception handler- Returns:
- the wrapped function
-
wrap
public static <I1,I2, BiFunction<I1,O> I2, wrapO> (BiFunctionWithException<I1, I2, O> func, Consumer<Exception> handler) Wrap aBiFunctionWithException
to aBiFunction
.- Type Parameters:
I1
- the input one typeI2
- the input two typeO
- the output type- Parameters:
func
- the functionhandler
- the exception handler- Returns:
- the wrapped function
-
wrap
Wrap aConsumerWithException
to aConsumer
.- Type Parameters:
I
- the input type- Parameters:
consumer
- the consumerhandler
- the exception handler- Returns:
- the wrapped consumer
-
wrap
Wrap aSupplierWithException
to aSupplier
.- Type Parameters:
O
- the output type- Parameters:
supplier
- the supplierhandler
- the exception handler- Returns:
- the wrapped supplier
-
wrap
Wrap aVoidFunctionWithException
to aVoidFunction
.- Parameters:
func
- the functionhandler
- the exception handler- Returns:
- the wrapped function
-