DecisionDag with a DSL based on Commons Jexl
- Language should be easy to understand -- The mythical business user should be able to use it without assistance
- Trivial translation from a decision diagram
- Enforce Acyclic nature via Loop detection
- Ensure that only declared variables are used in decisions
- Ability to define constants
- Ability inject utility classes for use in expression.
See tests for usage.
// A result is returned by prefixing it with ':'
// So :Cinema will end the rule processing and return 'Cinema'
// Otherwise it is interpreted as the name of a rule to execute next.
// Implementing
// http://study.com/academy/lesson/what-is-a-decision-tree-examples-advantages-role-in-management.html
var family_visiting;
var weather
var money
var known_weathers = {"sunny", "rainy", "windy" }
var rich_money = {"rich", "wealthy"}
start; if family_visiting=='yes' then :Cinema
// The "not in" operator is implemented as !~
// !known_weathers.contains(weather)
if weather !~ known_weathers then :ERROR
if weather=='sunny' then :Play Tennis
if weather=='rainy' then :Stay In
// The "in" operator is implemented as =~
// rich_money.contains(money)
if money =~ rich_money then :Shopping
if money == 'poor' then :Cinema else :ERROR