net.openhft.chronicle.testframework.internal.function.VanillaThrowingConsumer Maven / Gradle / Ivy
package net.openhft.chronicle.testframework.internal.function;
import net.openhft.chronicle.testframework.function.ThrowingConsumer;
import net.openhft.chronicle.testframework.function.ThrowingConsumerException;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
import static java.util.Objects.requireNonNull;
public final class VanillaThrowingConsumer implements Consumer {
private final ThrowingConsumer delegate;
public VanillaThrowingConsumer(@NotNull final ThrowingConsumer delegate) {
this.delegate = requireNonNull(delegate);
}
@Override
public void accept(T t) {
try {
delegate.accept(t);
} catch (Exception e) {
throw new ThrowingConsumerException(e);
}
}
}