流口水和地图 [英] Drools and Maps
本文介绍了流口水和地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的例子看起来像这样:
我是这个框架的初学者,我试图使用一个映射而不是Java类。 b
$ b
主要方法:
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:
ruleLow BMI
当
$ map:(Map(values(BMI))<18.0)
然后
System.out .println(你有一个低BMI);
end
我想在规则前提条件下比较BMI的值,是真的,所以我想显示下面的消息。
有什么不对?
解决方案你应该这样写:
when
$ map:Map(this [BMI ]< 18)
然后
它应该工作:)
I'm beginner in this framework and I'm trying to use a map instead of Java class.
My example looks like that:
Main method:
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
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.
What's it wrong?
解决方案
You should write something like:
when
$map: Map(this["BMI"] < 18)
then
It should work :)
这篇关于流口水和地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文