public final class Callbacks
extends java.lang.Object
| Constructor and Description |
|---|
Callbacks() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
doNothing(T ignored)
Empty consumer.
|
static <T> T |
identity(T input)
Identity Function.
|
static <T1,T2> void |
invokeSafely(java.util.function.BiConsumer<T1,T2> consumer,
T1 argument1,
T2 argument2,
java.util.function.Consumer<java.lang.Throwable> failureHandler)
Invokes the given Consumer with the given argument, and catches any exceptions that it may throw.
|
static <T> void |
invokeSafely(java.util.function.Consumer<T> consumer,
T argument,
java.util.function.Consumer<java.lang.Throwable> failureHandler)
Invokes the given Consumer with the given argument, and catches any exceptions that it may throw.
|
public static <T> void doNothing(T ignored)
T - Return type. Ignored.ignored - Ignored argument.public static <T> T identity(T input)
T - Type of the input.input - The input.public static <T> void invokeSafely(java.util.function.Consumer<T> consumer,
T argument,
java.util.function.Consumer<java.lang.Throwable> failureHandler)
T - The type of the argument.consumer - The consumer to invoke.argument - The argument to pass to the consumer.failureHandler - An optional callback to invoke if the consumer threw any exceptions.java.lang.NullPointerException - If the consumer is null.public static <T1,T2> void invokeSafely(java.util.function.BiConsumer<T1,T2> consumer,
T1 argument1,
T2 argument2,
java.util.function.Consumer<java.lang.Throwable> failureHandler)
T1 - The type of the first argument.T2 - The type of the second argument.consumer - The consumer to invoke.argument1 - The first argument to pass to the consumer.argument2 - The second argument to pass to the consumer.failureHandler - An optional callback to invoke if the consumer threw any exceptions.java.lang.NullPointerException - If the consumer is null.