org.codehaus.httpcache4j.util.ThrowableFunction Maven / Gradle / Ivy
The newest version!
package org.codehaus.httpcache4j.util;
import java.util.function.Function;
@FunctionalInterface
public interface ThrowableFunction {
B apply(A input) throws E;
@SuppressWarnings("unchecked")
static T sneakyRethrow(Throwable t) throws T {
throw (T) t;
}
default Function toFunction() {
return a -> {
try {
return this.apply(a);
} catch (Exception e) {
throw ThrowableFunction.sneakyRethrow(e);
}
};
}
static Function lift(ThrowableFunction f) {
return f.toFunction();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy