Karn_way
Karn_way

Reputation: 1015

How to get string from List<String> by JBOSS Drools

i have a List<String> i want something as below

Rule "List_iterate"
 when
   $str : String from List<String>
 then 
    // some action of $str

Upvotes: 2

Views: 1099

Answers (1)

Esteban Aliverti
Esteban Aliverti

Reputation: 6322

Using Lists as facts is not a good practice. It is always convenient to use a wrapper class. But if you want to go with the List you could write something like this:

Rule "List_iterate"
when
  $list : List()   //Be careful, this will match against all the Lists you have in your session.
  $str : String() from $list
then 
  // some action of $str
end

Hope it helps.

Upvotes: 2

Related Questions