Drools Decision Table Set List To Pojo - Java @ Desk

Sunday, July 22, 2018

Drools Decision Table Set List To Pojo

Drools Decision Table Set List To Pojo

In this post, we will learn how to set a list of values into a pojo field in Decision Table in the ACTION part. The values are set into the list field using the comma seperated values of Strings.

Consider a pojo class Person with following properties

1) age - Number
2) applyingFor - Pan/Adhaar/Passport(String)
3) documentsList - java.util.List - Documents required for application of Pan Card or Adhaar Card or Passport. It will be a String values seperated by comma

Following are the rules that are applied

1) If age > 18 and applyingFor = 'Pan Card', then documentsList = 'Birth Certificate', 'Photo'
2) If age > 18 and applyingFor = 'Adhaar Card', then documentsList = 'Birth Certificate', 'Pan Card', 'Light Bill', 'Photo'
3) If age > 18 and applyingFor = 'Pan Card', then documentsList = 'Adhaar Card', 'Pan Card', 'Photo'

This will be configured into a decision table as shown below


As shown, list is set using - $documentCheck.setDocumentList(Arrays.asList($param));





No comments:

Post a Comment