下面是我的课:
public class NumberDetails {
private String a ;
private String b;
private String c;
private String status;
private String result;
// getters and setters
}
初始化值 状态:302,a =“ A”,b =“ 2”
我必须运用逻辑:
if(status=302){
result = a+b;
}
如何在.drl文件中编写此内容?
rule "302 case"
when
numberObject: NumberDetails(status==302)
then
numberObject.setResult(numberObject(a)+numberObject(b)); // I know this is wrong but how to write it ?
end
答案 0 :(得分:0)
您可以使用private fun isNameValid(name: String?): LiveData<Boolean> {
var namesValid = false
if (!name.isNullOrEmpty()) {
namesValid = true
}
val mediatorLiveData: MediatorLiveData<Boolean> = MediatorLiveData()
mediatorLiveData.value = namesValid
return mediatorLiveData
}
方法来获取 firstNamesValid = Transformations.switchMap(firstName) { firstName -> isNameValid(firstName) }
lastNamesValid = Transformations.switchMap(lastName) { lastName -> isNameValid(lastName) }
中的值。例如,您可以将规则写为:
getter and setter