anataliocs
8/10/2015 - 5:01 PM

A Java 8 class to handle checked exceptions

A Java 8 class to handle checked exceptions

public interface Nonchalantly<T> {
    static <T> T invoke(Nonchalantly<T> f) {
        try {
            return f.run();
        } catch (Throwable e) {
            throw new RuntimeException( e );
        }
    }

    T run() throws Throwable;
    
    // USAGE
    // BeanInfo beanInfo = Nonchalantly.invoke(() -> Introspector.getBeanInfo(iface));
}