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

Add Functions.not(Predicate), and(Predicate...), or(Predicate...) #54

Closed ajermakovics closed 9 years ago

ajermakovics commented 10 years ago

Hello

Since there is no not(Predicate) function in Java 8: http://stackoverflow.com/q/21488056/1180621

seems like it would be a useful addition to jOOL.

lukaseder commented 10 years ago

There's Predicate.negate() for that...

ajermakovics commented 10 years ago

Sure, but it's not always convenient to use it. You have to cast your method reference to a Predicate. From SO question:

((Predicate<String>) String::isEmpty).negate()

could be made into more readable:

not(String::isEmpty)
lukaseder commented 10 years ago

I see. You're right, that could fit somewhere. I'll have to think about a more general strategy to integrate such utility methods... There's probably room for more

ajermakovics commented 10 years ago

Guava has not in a class called Predicates, so that could be one option.

lukaseder commented 10 years ago

I personally don't like to have dozens of classes all with their own static methods. I prefer having one single entry point for all sorts of DSL functionality. This has proven to be very effective with jOOQ, where all static SQL functions are available from org.jooq.impl.DSL. The API learning curve is very slim.