Skip to content

Commit a38581a

Browse files
feat: syntax sugar
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent df7c792 commit a38581a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import net.sf.jsqlparser.expression.operators.arithmetic.Modulo;
2222
import net.sf.jsqlparser.expression.operators.arithmetic.Multiplication;
2323
import net.sf.jsqlparser.expression.operators.arithmetic.Subtraction;
24+
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
25+
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
26+
import net.sf.jsqlparser.expression.operators.conditional.XorExpression;
2427
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
2528

2629
import java.lang.reflect.InvocationTargetException;
@@ -189,6 +192,36 @@ public static Expression subtract(Expression... expressions) {
189192
}
190193
}
191194

195+
public static Expression or(Expression... expressions) {
196+
try {
197+
return build(OrExpression.class, expressions);
198+
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
199+
| IllegalAccessException e) {
200+
// this should never happen, at least I don't see how
201+
throw new RuntimeException(e);
202+
}
203+
}
204+
205+
public static Expression xor(Expression... expressions) {
206+
try {
207+
return build(XorExpression.class, expressions);
208+
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
209+
| IllegalAccessException e) {
210+
// this should never happen, at least I don't see how
211+
throw new RuntimeException(e);
212+
}
213+
}
214+
215+
public static Expression and(Expression... expressions) {
216+
try {
217+
return build(AndExpression.class, expressions);
218+
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
219+
| IllegalAccessException e) {
220+
// this should never happen, at least I don't see how
221+
throw new RuntimeException(e);
222+
}
223+
}
224+
192225
public Expression getLeftExpression() {
193226
return leftExpression;
194227
}

0 commit comments

Comments
 (0)