[rules-users] Size and contains methods of List in Drools

Sumit Dhaniya sumitdhaniya at gmail.com
Mon Jun 23 11:10:20 EDT 2014


Is it possible write conditions on the basis of size of a list using guided
editors (either guided decision table or guided rule) and to check if any
element is present in the list?

For eg.

User { 
    List of badges;
}
now I want to apply condition on number of badges and if a specific badge is
in user's list of badges.

Also can I compare to objects. For eg. condition on count of badges of two
users?

I'm using KIE Drools Workbench

Here's how source code should look like :-

import com.demo.dto.User;
import com.demo.dto.Badge;

rule  "Compare two variables"

when 
$user: User(name == "Sam")
$badge: Badge() memberOf $user.getBadges()

then
$user.setImpact($user.getImpact + $user.getBadges().size())



--
View this message in context: http://drools.46999.n3.nabble.com/Size-and-contains-methods-of-List-in-Drools-tp4030137.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list