Java library for parsing and building logical expressions

Java library for parsing and building logical expressions … here is a solution to the problem.

Java library for parsing and building logical expressions

I’m looking for a Java open source library for parsing and building SQL-like expressions.

For example, evaluate the validity of an expression:

 "(a = x or y ) and (b != z)"

Also, I want an API for building or extending expressions.
Something like this:

Expression exp = new Expression();
exp.addCondition("a",{"x","y"},Operator.OR);

Implementing such a library is not complicated, but aren’t we developing in Java to enjoy collaborative development?

Best Solution

I’m pretty sure you can have ANTLR do this for you.

The syntax looks simple (from here) 😛

Related Problems and Solutions