How to combine conditions in jOOQ

I have a list of conditions:

List<Condition> conditions = ...;

What is the easiest way to and / or combine (or or combine) these conditions into a new condition?

Condition condition = and(conditions);

Does JOOQ have a utility function? I agree that it is easy to write, but I would prefer not to reinvent the wheel.

+4
source share
1 answer

jOOQ 3.6+.

You can simply write:

Condition condition = DSL.and(conditions);

Prior to jOOQ 3.6:

Before this was implemented in jOOQ 3.6 ( # 3904 ), you had to resort to writing your own method:

static Condition and(Collection<? extends Condition> conditions) {
    Condition result = DSL.trueCondition();

    for (Condition condition : conditions)
        result = result.and(condition);

    return result;
}
+7
source

All Articles