All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.yudichev.jiotty.common.lang.MoreThrowables Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package net.yudichev.jiotty.common.lang;

public final class MoreThrowables {
    private MoreThrowables() {
    }

    public static void asUnchecked(CheckedExceptionThrowingRunnable action) {
        try {
            action.run();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static  T getAsUnchecked(CheckedExceptionThrowingSupplier supplier) {
        try {
            return supplier.get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @FunctionalInterface
    public interface CheckedExceptionThrowingRunnable {
        @SuppressWarnings("ProhibitedExceptionDeclared")
            // by design
        void run() throws Exception;
    }

    @FunctionalInterface
    public interface CheckedExceptionThrowingSupplier {
        @SuppressWarnings("ProhibitedExceptionDeclared")
            // by design
        T get() throws Exception;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy