0

如何从 Drools 5.5 中收集的结果项 ArrayList 访问获取器?

在类似于下面示例的代码中,我得到The method getStatus() is undefined for the type Object.

我试过铸造结果,我试过 generics ArrayList<Alarm>

归根结底,我试图访问ArrayList().

rule "Raise priority if system has more than 3 pending alarms"
when
    $system : System()
    $alarms : ArrayList( size >= 3 )
              from collect( Alarm( system == $system, status == 'pending' ) )
then
    System.out.println($alarms.get(0)); // show Alarm.toString() 
    System.out.println($alarms.get(0).getClass()); // prints "Alarm"
    System.out.println($alarms.get(0).getStatus());

   // Raise priority, because system $system has
   // 3 or more alarms pending. The pending alarms
   // are $alarms.
end
4

0 回答 0