使用 drools DRL 文件从 arryalist 获取最后一个元素

Get last element from arryalist using drools DRL file

我正在尝试以下代码

rule "Last activity"
salience 1
when
  $notification : NotificationVO()
  lastActivityOffset:Integer()
  from  $notification.offsetChngesInterval.
  get($notification.offsetChngesInterval.size()-1)
then
  System.out.println("Hello--"+$notification.offsetChngesInterval.size());
end

它给出了错误java.lang.reflect.InvocationTargetException。 谁能在线上告诉我是什么导致了这个问题

$notification.offsetChngesInterval.
get($notification.offsetChngesInterval.size()-1)

它不允许我从列表中获取最后一个元素

宜写

$notification : NotificationVO( offsetChngesIntervall != null && offsetChngesInterval.size() > 0 )

以确保列表不为空。也许还要检查它是否不为空。