Refactoring

pull/215/head
M66B 8 months ago
parent d337763a77
commit 613f72e769

@ -673,11 +673,13 @@ public class EntityRule {
public EvaluationValue evaluate( public EvaluationValue evaluate(
Expression expression, Token operatorToken, EvaluationValue... operands) { Expression expression, Token operatorToken, EvaluationValue... operands) {
Log.i("EXPR " + operands[0] + (regex ? " MATCHES " : " CONTAINS ") + operands[1] + " regex=" + regex); Log.i("EXPR " + operands[0] + (regex ? " MATCHES " : " CONTAINS ") + operands[1] + " regex=" + regex);
String condition = operands[1].getStringValue(); String condition = operands[1].getStringValue();
List<EvaluationValue> array = operands[0].getArrayValue(); List<EvaluationValue> array = operands[0].getArrayValue();
if (!TextUtils.isEmpty(condition) && array != null) { if (TextUtils.isEmpty(condition) || array == null || array.isEmpty())
return expression.convertValue(false);
Pattern p = (regex ? Pattern.compile(condition, Pattern.DOTALL) : null); Pattern p = (regex ? Pattern.compile(condition, Pattern.DOTALL) : null);
Log.i("EXPR regex=" + (p == null ? null : p.pattern()));
for (EvaluationValue item : array) { for (EvaluationValue item : array) {
String value = item.getStringValue(); String value = item.getStringValue();
if (!TextUtils.isEmpty(value)) if (!TextUtils.isEmpty(value))
@ -689,7 +691,7 @@ public class EntityRule {
return expression.convertValue(true); return expression.convertValue(true);
} }
} }
}
return expression.convertValue(false); return expression.convertValue(false);
} }
} }

Loading…
Cancel
Save