Skip to content

Instantly share code, notes, and snippets.

@anataliocs
Forked from poetix/Nonchalantly.java
Last active August 29, 2015 14:27
Show Gist options
  • Save anataliocs/f017a86b398f37bc6dba to your computer and use it in GitHub Desktop.
Save anataliocs/f017a86b398f37bc6dba to your computer and use it in GitHub Desktop.
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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment