Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drools rule to check a collection with compound value restriction

I want to check if a collection contains not three elements. In java I would do

!(collection.contains("s1") && collection.contains("s2") && collection.contains("s3"))

How can I do this with drools? I searched for two hours and tried anything but can't find a solution for this "simple" problem. I found the "Compound Value Restriction" which is what I exactly need, but it does not work for collections and the "contains" operator.

I would appreciate your answers.

Nathanael

like image 839
Nathanael Avatar asked Dec 05 '25 19:12

Nathanael


1 Answers

This does what the Java code does:

Collection( this not contains "s1" ||
            this not contains "s2" ||
            this not contains "s3")
like image 125
Toni Rikkola Avatar answered Dec 11 '25 06:12

Toni Rikkola