Skip to content

Commit

Permalink
feat: syntax sugar
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
  • Loading branch information
manticore-projects committed Apr 15, 2024
1 parent df7c792 commit a38581a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import net.sf.jsqlparser.expression.operators.arithmetic.Modulo;
import net.sf.jsqlparser.expression.operators.arithmetic.Multiplication;
import net.sf.jsqlparser.expression.operators.arithmetic.Subtraction;
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
import net.sf.jsqlparser.expression.operators.conditional.XorExpression;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;

import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -189,6 +192,36 @@ public static Expression subtract(Expression... expressions) {
}
}

public static Expression or(Expression... expressions) {
try {
return build(OrExpression.class, expressions);
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
| IllegalAccessException e) {
// this should never happen, at least I don't see how
throw new RuntimeException(e);
}
}

public static Expression xor(Expression... expressions) {
try {
return build(XorExpression.class, expressions);
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
| IllegalAccessException e) {
// this should never happen, at least I don't see how
throw new RuntimeException(e);
}
}

public static Expression and(Expression... expressions) {
try {
return build(AndExpression.class, expressions);
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
| IllegalAccessException e) {
// this should never happen, at least I don't see how
throw new RuntimeException(e);
}
}

public Expression getLeftExpression() {
return leftExpression;
}
Expand Down

0 comments on commit a38581a

Please sign in to comment.