Search code examples
javadrools

Setting list from drools decision table


I am using drools for implementing certain condtion.I don't know how to set the arraylist of the bean in action from drools decision table.For example following is my class.

public class Dog implements Serializable{

 private String id;
 private List<String> names;

}

My decision table should set the list of names based on the id paseed.How to implement this?

Conditon    Action
d:Dog
id          ???(what needs to be done here)
1           "tom","jack","pearl"

Solution

  • This can be done in the usual way.

    Condition    Action
    d:Dog        d.getNames()
    id           addAll(Arrays.asList($param))
    Match id!    Add some names!   
    1            "tom","jack","pearl"
    

    You'll have to import Arrays or use the full class name.