Francesco
Francesco

Reputation: 907

Drools dslr - passing a list

In a dslr, can you pass a list of values to a condition or Drools is limited to one single value?

I would like to write something like:

[condition][]The customer firstName is in this list {nameList}=...

instead of

[condition][]The customer firstName is {name1} or {name2} or {name3}=...

Upvotes: 0

Views: 556

Answers (1)

laune
laune

Reputation: 31290

The DRL construct that fits is the compound restriction using "in", written as e.g.

Person( name in ("Joe", "Tom", "Fred") )

In your case the DSLR definition should be

[condition][]The customer firstName is in this list {nameList}=
    Customer( firstName in ({nameList}) )

Note that in the DSL you'll have to write the names in quotes:

The customer firstName is in this list "Joe","Tom","Fred"

Upvotes: 3

Related Questions