public class CheckedToRuntime { public static T get(final Supplier fun) { return fun.get(); } public static T c2r(final Supplier fun) { return fun.get(); } public static void run(final Runner fun) { fun.run(); } public static void c2r(final Runner fun) { fun.run(); } @FunctionalInterface public static interface Supplier { /** * Gets a result. * * @return a result */ T getThrow() throws E; default T get() { try { return this.getThrow(); } catch (final Throwable e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } } } @FunctionalInterface public static interface Runner { void runThrow() throws E; default void run() { try { this.runThrow(); } catch (final Throwable e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } } } }