org.ethelred.util.function.CheckedRunnable Maven / Gradle / Ivy
The newest version!
/* (C) 2024 */
package org.ethelred.util.function;
/**
* Checked wrapper for a Runnable
* @param A checked exception type that is thrown by the operation
*/
@FunctionalInterface
public interface CheckedRunnable {
void run() throws E;
default Runnable asUnchecked() {
return () -> {
try {
run();
} catch (Throwable e) {
throw new WrappedCheckedException(e);
}
};
}
static Runnable unchecked(CheckedRunnable runnable) {
return runnable.asUnchecked();
}
}