Replies: 2 comments
-
Greetings. You can define a |
Beta Was this translation helpful? Give feedback.
0 replies
-
private static String test(BinaryExpression expr) {
boolean test;
final ArrayList<Expression> expressions = new ArrayList<>();
ExpressionVisitorAdapter expressionVisitorAdapter = new ExpressionVisitorAdapter();
expr.accept(new ExpressionVisitorAdapter() {
protected void visitBinaryExpression(BinaryExpression expr) {
if (expr instanceof ComparisonOperator) {
ComparisonOperator comparisonOperator = (ComparisonOperator) expr;
Expression leftExpression = comparisonOperator.getLeftExpression();
String operator = comparisonOperator.getStringExpression();
Expression rightExpression = comparisonOperator.getRightExpression();
System.out.println("left=" + leftExpression + " op="
+ operator + " right=" + rightExpression);
expressions.add(leftExpression);
expressions.add(rightExpression);
}
super.visitBinaryExpression(expr);
}
});
StringBuilder builder = new StringBuilder();
for (Expression expression:expressions)
builder.append(expression.toString());
return builder.toString();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I saw I can get from a Expression the left, operator and right side...
I would like to extract that into a List to do something else later on...
What I´m trying to do is to get the whole Expression:
` private static String test(BinaryExpression expr) {
Is there a possibility to get this? Due tot he fact it´s procted I cannot add a List<> from outside the :
expr.accept(new ExpressionVisitorAdapter() {
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions