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