Package io.smallrye.common.function
Class Functions
- java.lang.Object
-
- io.smallrye.common.function.Functions
-
public final class Functions extends Object
A set of utility methods which return common functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U>
RunnablecapturingRunnable(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>consumerBiConsumer()Get the singleton consumer which accepts a consumer and an argument to hand to it.static <T> ExceptionBiConsumer<Consumer<T>,T,RuntimeException>consumerExceptionBiConsumer()Get the singleton consumer which accepts a consumer and an argument to hand to it.static <T,U>
BiConsumer<T,U>discardingBiConsumer()Get a consumer which discards the values it is given.static <T> Consumer<T>discardingConsumer()Get a consumer which discards the values it is given.static <T,U,E extends Exception>
ExceptionBiConsumer<T,U,E>discardingExceptionBiConsumer()Get a consumer which discards the values it is given.static <T,E extends Exception>
ExceptionConsumer<T,E>discardingExceptionConsumer()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>exceptionConsumerBiConsumer()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>exceptionFunctionBiFunction()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>exceptionRunnableConsumer()Get the singleton exception consumer which accepts and runs exception runnable instances.static <R,E extends Exception>
ExceptionFunction<ExceptionSupplier<R,E>,R,E>exceptionSupplierFunction()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>exceptionSupplierFunctionBiFunction()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>functionBiFunction()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>functionExceptionBiFunction()Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.static Consumer<Runnable>runnableConsumer()Get the singleton consumer which accepts and runs runnable instances.static ExceptionConsumer<Runnable,RuntimeException>runnableExceptionConsumer()Get the singleton exception consumer which accepts and runs runnable instances.static <R> ExceptionFunction<Supplier<R>,R,RuntimeException>supplierExceptionFunction()Get the singleton function which accepts a supplier and returns the result of the supplier.static <R> Function<Supplier<R>,R>supplierFunction()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>supplierFunctionBiFunction()Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.
-
-
-
Method Detail
-
runnableConsumer
public static Consumer<Runnable> 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
public static ExceptionConsumer<Runnable,RuntimeException> runnableExceptionConsumer()
Get the singleton exception consumer which accepts and runs runnable instances.- Returns:
- the runnable consumer
-
consumerBiConsumer
public static <T> BiConsumer<Consumer<T>,T> 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>,T,E> exceptionConsumerBiConsumer()
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
public static <T> ExceptionBiConsumer<Consumer<T>,T,RuntimeException> 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
public static <R> Function<Supplier<R>,R> 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>,R,E> exceptionSupplierFunction()
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
public static <R> ExceptionFunction<Supplier<R>,R,RuntimeException> 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
public static <R> BiFunction<Function<Supplier<R>,R>,Supplier<R>,R> 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>,R,E>,ExceptionSupplier<R,E>,R,E> exceptionSupplierFunctionBiFunction()
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
public static <T,R> BiFunction<Function<T,R>,T,R> 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,E extends Exception> ExceptionBiFunction<ExceptionFunction<T,R,E>,T,R,E> exceptionFunctionBiFunction()
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>,T,R,RuntimeException> functionExceptionBiFunction()
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
public static <T> Supplier<T> constantSupplier(T value)
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
public static <T,E extends Exception> ExceptionSupplier<T,E> constantExceptionSupplier(T value)
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
public static <T,U> Runnable capturingRunnable(BiConsumer<T,U> 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 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
public static <T> Runnable capturingRunnable(Consumer<T> consumer, T param)
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,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.- 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
public static <T> Consumer<T> discardingConsumer()
Get a consumer which discards the values it is given.- Type Parameters:
T- the parameter type- Returns:
- the discarding consumer
-
discardingExceptionConsumer
public static <T,E extends Exception> ExceptionConsumer<T,E> 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
public static <T,U> BiConsumer<T,U> 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,E extends Exception> ExceptionBiConsumer<T,U,E> discardingExceptionBiConsumer()
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
-
-