public class Policy{
String accntCode;
String currency;
String flag;
}
为每个人生成和getter setter。
现在,如果flag
不是"Y"
且currency
以"INR"
开头,我需要将accntCode
的值设置为"P"
。请帮助我,因为我是Drool的新手。
我使用
创建了类Policy
的对象策略
Policy policy = new Policy();
还请告诉我是否有任何方法可以在eclipse中调试Drool,就像我们对java代码一样。
答案 0 :(得分:0)
在Drools中你需要:
rule "Raise flag if currency isn't INR"
when
$p : Policy ( getCurrency() != "INR" )
then
$p.setFlag("Y")
您需要在Java端创建适当的getter和setter。
答案 1 :(得分:0)
以下规则应该有效:
rule "Set flag \"Y\" when accntCode starts with 'P' and currency is not \"INR\""
when
a : Applicant(currency != "INR", accntCode str[startsWith] "P" )
then
a.setFlag("Y");
System.out.println(a.getAccntCode() + "\t" + a.getCurrency() + "\t" + a.getFlag());
end
rule "Set flag \"N\" when accntCode doesn't start with 'P' and currency is not \"INR\""
when
a : Applicant(currency != "INR")
not Applicant(accntCode str[startsWith] "P" )
then
a.setFlag("N");
System.out.println(a.getAccntCode() + "\t" + a.getCurrency() + "\t" + a.getFlag());
end
所以,当事实是
app.setAccntCode("PHD");
app.setCurrency("EURO");
你会得到
PHD EURO Y
事实是
app2.setAccntCode("HD");
app2.setCurrency("EURO");
你会得到
HD EURO N