io.castled.exceptions.NonThrowingFunction Maven / Gradle / Ivy
package io.castled.exceptions;
import io.castled.functionalinterfaces.ThrowingFunction;
import java.util.function.Function;
public class NonThrowingFunction implements Function {
private final ThrowingFunction throwingFunction;
public NonThrowingFunction(ThrowingFunction throwingFunction) {
this.throwingFunction = throwingFunction;
}
@Override
public R apply(T t) {
try {
return throwingFunction.apply(t);
} catch (Exception e) {
throw new CastledRuntimeException(e);
}
}
}