这是我的drools验证问题的第二部分。第一部分已经得到解答,我的代码中已经提出了解决方案。 First Part
这是我的java类结构
public class Person {
List<PersonAddress> personAddress;
List<FinanceDetails> financeDetails;
}
public enum AddressStatus {
CURRENT, PREVIOUS;
}
public enum AddressType {
PHYSICAL, POSTAL;
}
public enum AddressUseType {
HOME, OFFICE;
}
public class PersonAddress{
Address address;
AddressType type
AddressStatus status
AddressUseType useType
String ownerShipType
Integer timeAtAddress;
}
public class Address {
String city;
String country;
String street;
}
public class FinanceDetails {
String financeItemName;
BigDecimal itemValue;
}
好的我的问题是,如果financeItemName是&#34; Land或Building&#34;,如果此用户的地址符合以下条件,我需要验证FinanceDetails实例的itemValue,
AddressStatus == CURRENT
AddressType == PHYSICAL
AddressUseType == HOME
ownerShipType ==&#34;拥有&#34;
Drools版本5.5.0.Final
Java 1.7
可以使用功能
需要示例流氓规则语法。谢谢
答案 0 :(得分:1)
添加了itemValue测试,如某些评论中所示
rule "land-orbuilding..."
when
Peson( $financeDetails: financeDetails, $personAddress: personAddress )
FinanceDetails( financeItemName == "Land or Building", itemValue == null || itemValue == 0 ) from $financeDetails
PersonAddress( status == AddressStatus.CURRENT,
type == AddressType.PHYSICAL,
useType == AddressUseType.HOME,
ownerShipType == "Own" ) from $personAddress
then
//...
end
阅读一些文档怎么样?这非常像“第一部分”,只是一个微小的变化。
答案 1 :(得分:0)
rule "Check Details"
when
details:FinanceDetails (itemValue == 'LAND' || == 'Building')
address:PersonAddress(status == AddressStatus.CURRENT,
type == AddressType.PHYSICAL,
useType == AddressUseType.HOME,
ownerShipType == "Own" )
then
modify(details){itemValue=//set your value};
end