简体   繁体   English

流口水收集图案问题

[英]Drools collect pattern problem

I have a rule LHS like that 我有这样的规则LHS

when 
    $location : Location() 
    $cabinets : ArrayList() from collect ( Cabinet() from $location.elements() )
then

an when I print the content of @cabinets in RHS I see that it contains all elements (also those that are not of class Cabinet ). 当我在RHS中打印@cabinets的内容时,我看到它包含所有元素(包括那些不是Cabinet类的元素)。

I want to collect ontly cabinets from $location>elements(). 我想从$ location> elements()收集橱柜。

What did I do wrong ? 我做错了什么 ?

I think you would say something along the lines of 我想你会说一些类似的话

Cabinet(class == Cabinet.class)

I dont think that Drools is doing an explicit type check on the Cabinet classes as you have them afaik. 我不认为Drools对afaik进行内阁类的显式类型检查。

Your question is about the 'from' pattern, not the 'collect' one. 您的问题是关于“从”模式,而不是“收集”模式。

Following rule should help to test: 以下规则应有助于测试:

when 
  $location : Location() 
  $cabinet : Cabinet() from $location.elements()
then

This rule should fire for each Cabinet in location. 该规则应在每个机柜中触发。

You can try to post your question on the rule-users user list 您可以尝试将问题发布到规则用户用户列表中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM