Java - Drools 验证对象值列表
Java - Drools validate list of object values
我想要我的 Drool 通用版。
这是我的 Java class 结构:
public class RulesModel {
private String field;
private List<Object> values;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public List<Object> getValues() {
return values;
}
public void setValues(List<Object> values) {
this.values = values;
}
}
我想要如下规则:
rule "sample"
when
$rule : RulesModel( field == "source", value == "facebook", value == "youtube", value != "instagram" )
then
// actions
end
如何在 Drools 中验证列表对象?
您要查找的是 contains
和 not contains
运算符:
(假设您的 RuleModel
包含 Strings
作为值)
rule "sample"
when
$rule : RulesModel( field == "source", values contains "facebook", values contains "youtube", value not contains "instagram" )
then
// actions
end
您可以在此处获取有关 Drools 支持的运算符的更多信息:https://docs.jboss.org/drools/release/7.37.0.Final/drools-docs/html_single/index.html#drl-operators-ref_drl-rules
希望对您有所帮助,
我想要我的 Drool 通用版。
这是我的 Java class 结构:
public class RulesModel {
private String field;
private List<Object> values;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public List<Object> getValues() {
return values;
}
public void setValues(List<Object> values) {
this.values = values;
}
}
我想要如下规则:
rule "sample"
when
$rule : RulesModel( field == "source", value == "facebook", value == "youtube", value != "instagram" )
then
// actions
end
如何在 Drools 中验证列表对象?
您要查找的是 contains
和 not contains
运算符:
(假设您的 RuleModel
包含 Strings
作为值)
rule "sample"
when
$rule : RulesModel( field == "source", values contains "facebook", values contains "youtube", value not contains "instagram" )
then
// actions
end
您可以在此处获取有关 Drools 支持的运算符的更多信息:https://docs.jboss.org/drools/release/7.37.0.Final/drools-docs/html_single/index.html#drl-operators-ref_drl-rules
希望对您有所帮助,