0

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}=...
Francesco
  • 857
  • 1
  • 11
  • 26

1 Answers1

3

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"
laune
  • 31,114
  • 3
  • 29
  • 42
  • thank you laune, this is what I was looking for. Is there a way also to access the list in the right hand bit of the DSLR? Something like: `[condition][]These 3 customers {customerList} have at least this age: {ageList}={customerList}[0].age == {ageList}[0] , ...` – Francesco Jan 15 '15 at 11:46
  • This will not result in valid DRL code, and I'm not sure what you are trying to do here. Perhaps you close this Q+A and start a new one with more background? – laune Jan 15 '15 at 11:51