io.castled.exceptions.NonThrowingConsumer Maven / Gradle / Ivy
package io.castled.exceptions;
import io.castled.functionalinterfaces.ThrowingConsumer;
import java.util.function.Consumer;
public class NonThrowingConsumer implements Consumer {
private final ThrowingConsumer throwingConsumer;
public NonThrowingConsumer(ThrowingConsumer throwingConsumer) {
this.throwingConsumer = throwingConsumer;
}
@Override
public void accept(T t) {
try {
throwingConsumer.accept(t);
} catch (Exception e) {
throw new CastledRuntimeException(e);
}
}
}