jOOQ / jOOL

jOOλ - The Missing Parts in Java 8 jOOλ improves the JDK libraries in areas where the Expert Group's focus was elsewhere. It adds tuple support, function support, and a lot of additional functionality around sequential Streams. The JDK 8's main efforts (default methods, lambdas, and the Stream API) were focused around maintaining backwards compatibility and implementing a functional API for parallelism.
http://www.jooq.org/products
Apache License 2.0
2.09k stars 168 forks source link

Support void/no-arg function wrapping in Unchecked? #317

Closed leaumar closed 7 years ago

leaumar commented 7 years ago

I seem to be missing a helper function in Unchecked that would allow me to wrap a method that neither takes arguments nor returns anything, just performs work and might throw an exception. I can find neither it nor a note explaining why it isn't there.

I mean something like this: image

Is there a reason why it doesn't exist, or could it be added in an update?

ansell commented 7 years ago

Is there a FunctionalInterface in the JVM with a void no-args method that throws an Exception to reuse? Runnable doesn't throw an exception, so it wouldn't fit the bill here.

lukaseder commented 7 years ago

org.jooq.lambda.fi.lang.CheckedRunnable seems to be the type you're looking for.

leaumar commented 7 years ago

Indeed, thanks! Overlooked it because I linked it with threading and those kind of Runnables...

lukaseder commented 7 years ago

Yeah, it's a historic type also in the JDK: java.lang.Runnable. There's no new Java 8 functional interface of that type, given that Runnable is already sufficient.