
com.chutneytesting.tools.ThrowingConsumer Maven / Gradle / Ivy
package com.chutneytesting.tools;
import java.util.function.Consumer;
@FunctionalInterface
public interface ThrowingConsumer {
void accept(T var1) throws Exception;
/**
* @throws UncheckedException if given {@link ThrowingFunction} throws
*/
static Consumer toUnchecked(ThrowingConsumer throwingConsumer) throws UncheckedException {
return silence(throwingConsumer, e -> {
throw UncheckedException.throwUncheckedException(e);
});
}
static Consumer silence(ThrowingConsumer throwingConsumer, Consumer exceptionHandler) {
return t -> {
try {
throwingConsumer.accept(t);
} catch (Exception e) {
exceptionHandler.accept(e);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy