public class FunctionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Callable<T> |
asCallable(RunnableWithException command,
T result)
|
static <T> Consumer<T> |
ignoreFn()
Consumer which ignores the input.
|
static <T> Function<T,Void> |
nullFn()
Function which returns
null (type: Void). |
static <A> Consumer<A> |
uncheckedConsumer(ThrowingConsumer<A,?> throwingConsumer)
Converts a
ThrowingConsumer into a Consumer which throws checked exceptions
as unchecked. |
static <A,B> Function<A,B> |
uncheckedFunction(FunctionWithException<A,B,?> functionWithException)
Convert at
FunctionWithException into a Function . |
static <T> Supplier<T> |
uncheckedSupplier(SupplierWithException<T,?> supplierWithException)
Converts a
SupplierWithException into a Supplier which throws all checked
exceptions as unchecked. |
public static <T> Function<T,Void> nullFn()
null
(type: Void).T
- input typenull
.public static <T> Consumer<T> ignoreFn()
T
- type of the inputConsumer
public static <A,B> Function<A,B> uncheckedFunction(FunctionWithException<A,B,?> functionWithException)
FunctionWithException
into a Function
.A
- input typeB
- output typefunctionWithException
- function with exception to convert into a functionFunction
which throws all checked exception as an unchecked exception.public static <A> Consumer<A> uncheckedConsumer(ThrowingConsumer<A,?> throwingConsumer)
ThrowingConsumer
into a Consumer
which throws checked exceptions
as unchecked.public static <T> Supplier<T> uncheckedSupplier(SupplierWithException<T,?> supplierWithException)
SupplierWithException
into a Supplier
which throws all checked
exceptions as unchecked.public static <T> Callable<T> asCallable(RunnableWithException command, T result)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.