Package org.wildfly.common.function
Class Functions
java.lang.Object
org.wildfly.common.function.Functions
A set of utility methods which return common functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> Runnable capturingRunnable(BiConsumer<T, U> consumer, T param1, U param2) Get a runnable which executes the given consumer with captured values.static <T> RunnablecapturingRunnable(Consumer<T> consumer, T param) Get a runnable which executes the given consumer with captured values.static <T,E extends Exception>
ExceptionSupplier<T,E> constantExceptionSupplier(T value) Get a supplier which always returns the same value.static <T> Supplier<T>constantSupplier(T value) Get a supplier which always returns the same value.static <T> BiConsumer<Consumer<T>,T> Get the singleton consumer which accepts a consumer and an argument to hand to it.static <T> ExceptionBiConsumer<Consumer<T>,T, RuntimeException> Get the singleton consumer which accepts a consumer and an argument to hand to it.static <T,U> BiConsumer<T, U> Get a consumer which discards the values it is given.static <T> Consumer<T>Get a consumer which discards the values it is given.static <T,U, E extends Exception>
ExceptionBiConsumer<T,U, E> Get a consumer which discards the values it is given.static <T,E extends Exception>
ExceptionConsumer<T,E> Get a consumer which discards the values it is given.static <T,U, E extends Exception>
ExceptionRunnable<E>exceptionCapturingRunnable(ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) Get a runnable which executes the given consumer with captured values.static <T,E extends Exception>
ExceptionRunnable<E>exceptionCapturingRunnable(ExceptionConsumer<T, E> consumer, T param) Get a runnable which executes the given consumer with captured values.static <T,E extends Exception>
ExceptionBiConsumer<ExceptionConsumer<T,E>, T, E> Get the singleton consumer which accepts a consumer and an argument to hand to it.static <T,R, E extends Exception>
ExceptionBiFunction<ExceptionFunction<T,R, E>, T, R, E> Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.static <E extends Exception>
ExceptionConsumer<ExceptionRunnable<E>,E> Get the singleton exception consumer which accepts and runs exception runnable instances.static <R,E extends Exception>
ExceptionFunction<ExceptionSupplier<R,E>, R, E> Get the singleton function which accepts a supplier and returns the result of the supplier.static <R,E extends Exception>
ExceptionBiFunction<ExceptionFunction<ExceptionSupplier<R,E>, R, E>, ExceptionSupplier<R, E>, R, E> Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.static <T,R> BiFunction<Function<T, R>, T, R> Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.static <T,R> ExceptionBiFunction<Function<T, R>, T, R, RuntimeException> Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.Get the singleton consumer which accepts and runs runnable instances.Get the singleton exception consumer which accepts and runs runnable instances.static <R> ExceptionFunction<Supplier<R>,R, RuntimeException> Get the singleton function which accepts a supplier and returns the result of the supplier.Get the singleton function which accepts a supplier and returns the result of the supplier.static <R> BiFunction<Function<Supplier<R>,R>, Supplier<R>, R> Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.
-
Method Details
-
runnableConsumer
Get the singleton consumer which accepts and runs runnable instances.- Returns:
- the runnable consumer
-
exceptionRunnableConsumer
public static <E extends Exception> ExceptionConsumer<ExceptionRunnable<E>,E> exceptionRunnableConsumer()Get the singleton exception consumer which accepts and runs exception runnable instances.- Type Parameters:
E- the exception type- Returns:
- the runnable consumer
-
runnableExceptionConsumer
Get the singleton exception consumer which accepts and runs runnable instances.- Returns:
- the runnable consumer
-
consumerBiConsumer
Get the singleton consumer which accepts a consumer and an argument to hand to it.- Type Parameters:
T- the argument type- Returns:
- the consumer
-
exceptionConsumerBiConsumer
public static <T,E extends Exception> ExceptionBiConsumer<ExceptionConsumer<T,E>, exceptionConsumerBiConsumer()T, E> Get the singleton consumer which accepts a consumer and an argument to hand to it.- Type Parameters:
T- the argument typeE- the exception type- Returns:
- the consumer
-
consumerExceptionBiConsumer
Get the singleton consumer which accepts a consumer and an argument to hand to it.- Type Parameters:
T- the argument type- Returns:
- the consumer
-
supplierFunction
Get the singleton function which accepts a supplier and returns the result of the supplier.- Type Parameters:
R- the result type- Returns:
- the function
-
exceptionSupplierFunction
public static <R,E extends Exception> ExceptionFunction<ExceptionSupplier<R,E>, exceptionSupplierFunction()R, E> Get the singleton function which accepts a supplier and returns the result of the supplier.- Type Parameters:
R- the result typeE- the exception type- Returns:
- the function
-
supplierExceptionFunction
Get the singleton function which accepts a supplier and returns the result of the supplier.- Type Parameters:
R- the result type- Returns:
- the function
-
supplierFunctionBiFunction
Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.- Type Parameters:
R- the result type- Returns:
- the function
-
exceptionSupplierFunctionBiFunction
public static <R,E extends Exception> ExceptionBiFunction<ExceptionFunction<ExceptionSupplier<R,E>, exceptionSupplierFunctionBiFunction()R, E>, ExceptionSupplier<R, E>, R, E> Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.- Type Parameters:
R- the result typeE- the exception type- Returns:
- the function
-
functionBiFunction
Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.- Type Parameters:
T- the argument typeR- the result type- Returns:
- the function
-
exceptionFunctionBiFunction
public static <T,R, ExceptionBiFunction<ExceptionFunction<T,E extends Exception> R, exceptionFunctionBiFunction()E>, T, R, E> Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.- Type Parameters:
T- the argument typeR- the result typeE- the exception type- Returns:
- the function
-
functionExceptionBiFunction
public static <T,R> ExceptionBiFunction<Function<T,R>, functionExceptionBiFunction()T, R, RuntimeException> Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.- Type Parameters:
T- the argument typeR- the result type- Returns:
- the function
-
constantSupplier
Get a supplier which always returns the same value.- Type Parameters:
T- the value type- Parameters:
value- the value to return- Returns:
- the value supplier
-
constantExceptionSupplier
Get a supplier which always returns the same value.- Type Parameters:
T- the value typeE- the exception type- Parameters:
value- the value to return- Returns:
- the value supplier
-
capturingRunnable
Get a runnable which executes the given consumer with captured values.- Type Parameters:
T- the first parameter typeU- the second parameter type- Parameters:
consumer- the consumer to run (must not benull)param1- the first parameter to passparam2- the second parameter to pass- Returns:
- the capturing runnable
-
capturingRunnable
Get a runnable which executes the given consumer with captured values.- Type Parameters:
T- the parameter type- Parameters:
consumer- the consumer to run (must not benull)param- the parameter to pass- Returns:
- the capturing runnable
-
exceptionCapturingRunnable
public static <T,U, ExceptionRunnable<E> exceptionCapturingRunnableE extends Exception> (ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) Get a runnable which executes the given consumer with captured values.- Type Parameters:
T- the first parameter typeU- the second parameter typeE- the exception type- Parameters:
consumer- the consumer to run (must not benull)param1- the first parameter to passparam2- the second parameter to pass- Returns:
- the capturing runnable
-
exceptionCapturingRunnable
public static <T,E extends Exception> ExceptionRunnable<E> exceptionCapturingRunnable(ExceptionConsumer<T, E> consumer, T param) Get a runnable which executes the given consumer with captured values.- Type Parameters:
T- the parameter typeE- the exception type- Parameters:
consumer- the consumer to run (must not benull)param- the parameter to pass- Returns:
- the capturing runnable
-
discardingConsumer
Get a consumer which discards the values it is given.- Type Parameters:
T- the parameter type- Returns:
- the discarding consumer
-
discardingExceptionConsumer
Get a consumer which discards the values it is given.- Type Parameters:
T- the parameter typeE- the exception type- Returns:
- the discarding consumer
-
discardingBiConsumer
Get a consumer which discards the values it is given.- Type Parameters:
T- the first parameter typeU- the second parameter type- Returns:
- the discarding consumer
-
discardingExceptionBiConsumer
public static <T,U, ExceptionBiConsumer<T,E extends Exception> U, discardingExceptionBiConsumer()E> Get a consumer which discards the values it is given.- Type Parameters:
T- the first parameter typeU- the second parameter typeE- the exception type- Returns:
- the discarding consumer
-