Drools规则取决于JDK Map中的知识(不在非JDK类之内) [英] Drools Rule depending on Knowledge from JDK Map (not within non-JDK Class)
本文介绍了Drools规则取决于JDK Map中的知识(不在非JDK类之内)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写以下规则,这取决于下面的 main
中提供的知识,该知识仅使用JDK [library] Map(而不是非库类中的Map).但这似乎不起作用...
I'm trying to write the below Rule, which depends on Knowledge provided in the below main
that uses just a JDK [library] Map (instead of a Map within a non-library Class). But it doesn't seem to be working...
主要方法:
Map<String, Float> mapa = new HashMap<String, Float>();
mapa.put("Height", (float)1.73);
mapa.put("Weight", (float)79.0);
mapa.put("BMI", mapa.get("Weight") /
(mapa.get("Height") * mapa.get("Height")));
ksession.insert(mapa);
rule.drl:
rule "Low BMI"
when
$map : (Map(values("BMI")) < 18.0)
then
System.out.println("You have a low BMI");
end
我想在规则前提条件内比较BMI的值,如果该条件为true,那么我想在下面显示消息.
I want to compare the value of BMI inside of rule precondition, if this condition is true, so I want to show the message below.
怎么了?
推荐答案
您应编写以下内容:
when
$map: Map(this["BMI"] < 18)
then
应该可以:)
这篇关于Drools规则取决于JDK Map中的知识(不在非JDK类之内)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文