提交 38accbc9 编写于 作者: xuhui961310148's avatar xuhui961310148

add:支持数组内容相等、不相等判断,支持条件值动态取数

上级 4d87f11c
...@@ -620,8 +620,8 @@ public class ModelObj extends DataObj<String,Object> { ...@@ -620,8 +620,8 @@ public class ModelObj extends DataObj<String,Object> {
return val; return val;
} }
// return null;
return null; return this.$(exp).getValue();
} }
@JsonIgnore @JsonIgnore
......
...@@ -135,11 +135,48 @@ public class RuleUtils ...@@ -135,11 +135,48 @@ public class RuleUtils
else if (option.equalsIgnoreCase("NOTMATCHES")){ else if (option.equalsIgnoreCase("NOTMATCHES")){
return notmatchand(exp,finalObject); return notmatchand(exp,finalObject);
} }
else if (option.equalsIgnoreCase("EQARRAY")){
return eqarray(exp,finalObject);
}
else if (option.equalsIgnoreCase("NOTEQARRAY")){
return !eqarray(exp,finalObject);
}
else{ else{
return false; return false;
} }
} }
public static boolean eqarray(Object exp, Object finalObject) {
if(exp == null && finalObject == null){
return true;
}
if(exp == null){
return false;
}
if(finalObject ==null){
return false;
}
if (finalObject instanceof String){
String finalObjectArr [] = finalObject.toString().trim().split("[| ; ,]");
String expArr [] = exp.toString().trim().split("[| ; ,]");
if (finalObjectArr.length != expArr.length){
return false;
}
if (finalObjectArr.length == 0 && expArr.length == 0){
return true;
}
Arrays.sort(finalObjectArr);
Arrays.sort(expArr);
for (int i = 0; i < finalObjectArr.length; i++) {
if (!finalObjectArr[i].equals(expArr[i])){
return false;
}
}
return true;
}
return equal(exp,finalObject);
}
public static boolean equal(Object exp, Object object, String members) public static boolean equal(Object exp, Object object, String members)
{ {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册