Drools决策表-如何在同一条件列中使用多个对象

时间:2018-08-23 04:22:30

标签: drools

我有以下POJO:

1)

Class1

2)

public class InvoiceDetails{
    String currency;

    public String getCurrency(){
       return this.currency;
    }

    public void setCurrency(String currency){
      this.currency = currency;
    }
}

我想通过以下方式在我的Drools Decision表中创建一个条件:

public class ValidCurrencies {

    List<String> currencies = new ArrayList<String>();

    public ValidCurrencies() {
        currencies.add("JPY");
        currencies.add("USD");
        currencies.add("EUR");
        currencies.add("CNY");
    }

    public List<String> getCurrencies() {
        return currencies;
    }

    public void setCurrencies(List<String> currencies) {
        this.currencies = currencies;
    }
}

有人可以帮助编写Decison表语法来编写以下内容吗?

  • 如果我的发票对象包含任何CONDITION | ACTION $inv: InvoiceDetails $validCurr: ValidCurrencies | $param==$validCurr.getCurrencies().containsAll(Arrays.asList($inv.getCurrency())) TRUE FALSE
  • ,请执行操作#1
  • 如果我的发票对象不包含任何ValidCurrencies
  • ,请执行操作2。

1 个答案:

答案 0 :(得分:0)

我相信您可以通过这种方式完成

<table>
  <tr>
    <th>CONDITION</th>
    <th>CONDITION</th>
    <th>CONDITION</th>
    <th>ACTION</th>
  </tr>
  <tr>
    <td>$inv: InvoiceDetails</td>
    <td>$validCurr: ValidCurrencies</td>
    <td>$param==$validCurr.getCurrencies().contains($inv.getCurrency())</td>
    <td></td>
  </tr>
  <tr>
    <td>TRUE</td>
    <td>TRUE</td>
    <td>TRUE</td>
    <td>/**action 1**/</td>
  </tr>
  <tr>
    <td>TRUE</td>
    <td>TRUE</td>
    <td>false</td>
    <td>/**action 2**/</td>
  </tr>
</table>