Skip to content

Sharing ExpressionEvaluator instances #3339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class ExpressionEvaluator {

public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator();

public boolean evaluateBoolean(String expression, Object parameterObject) {
Object value = OgnlCache.getValue(expression, parameterObject);
if (value instanceof Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class ForEachSqlNode implements SqlNode {
public static final String ITEM_PREFIX = "__frch_";

private final ExpressionEvaluator evaluator;
private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE;
private final String collectionExpression;
private final Boolean nullable;
private final SqlNode contents;
Expand All @@ -53,7 +53,6 @@ public ForEachSqlNode(Configuration configuration, SqlNode contents, String coll
*/
public ForEachSqlNode(Configuration configuration, SqlNode contents, String collectionExpression, Boolean nullable,
String index, String item, String open, String close, String separator) {
this.evaluator = new ExpressionEvaluator();
this.collectionExpression = collectionExpression;
this.nullable = nullable;
this.contents = contents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
* @author Clinton Begin
*/
public class IfSqlNode implements SqlNode {
private final ExpressionEvaluator evaluator;
private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE;
private final String test;
private final SqlNode contents;

public IfSqlNode(SqlNode contents, String test) {
this.test = test;
this.contents = contents;
this.evaluator = new ExpressionEvaluator();
}

@Override
Expand Down
Loading