【问题标题】:RuleBook returns empty resultRuleBook 返回空结果
【发布时间】:2020-04-29 11:18:37
【问题描述】:

我正在使用规则书来创建规则链,如下所示:

RuleBookBuilder.create()
      .withResultType(Boolean.class)
            .addRule(
                RuleBuilder.create()
                    .withFactType(Double.class)
                    .withResultType(Boolean.class)
                    .when(facts -> facts.get("amount_gt").getValue() > new Double(600))
                    .then((facts, result) -> {
                      result.setValue(true);
                      System.out.println(result.getValue()); //1st print statement
                    })
                    .addRule()
                    ....
                    .build())

NameValueReferableMap facts = new FactMap();
facts.setValue("amount_gt", new Double(700));

rule.run(facts);
System.out.println(rule.getResult()); //2nd print statement

第一个 print 语句打印 true(例外),但第二个语句给出 Optional.empty 有人能告诉我可能出了什么问题吗?

【问题讨论】:

    标签: rule-engine


    【解决方案1】:

    您似乎将规则和您未显示的外部规则的返回联系起来。 如果您尝试访问内部规则的返回值,则需要类似地链接 get() 调用。

    我会尝试“解开”规则,看看会产生什么结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2021-05-01
      • 2017-08-25
      • 2013-09-27
      相关资源
      最近更新 更多