| 1 | |
package org.kuali.rice.krms.framework.engine; |
| 2 | |
|
| 3 | |
import org.kuali.rice.krms.api.engine.ExecutionEnvironment; |
| 4 | |
|
| 5 | |
public final class BasicAgendaTreeEntry implements AgendaTreeEntry { |
| 6 | |
|
| 7 | |
private final Rule rule; |
| 8 | |
private final AgendaTree ifTrue; |
| 9 | |
private final AgendaTree ifFalse; |
| 10 | |
|
| 11 | |
public BasicAgendaTreeEntry(Rule rule) { |
| 12 | 33 | this(rule, null, null); |
| 13 | 33 | } |
| 14 | |
|
| 15 | 37 | public BasicAgendaTreeEntry(Rule rule, AgendaTree ifTrue, AgendaTree ifFalse) { |
| 16 | 37 | if (rule == null) { |
| 17 | 0 | throw new IllegalArgumentException("rule was null"); |
| 18 | |
} |
| 19 | 37 | this.rule = rule; |
| 20 | 37 | this.ifTrue = ifTrue; |
| 21 | 37 | this.ifFalse = ifFalse; |
| 22 | 37 | } |
| 23 | |
|
| 24 | |
@Override |
| 25 | |
public void execute(ExecutionEnvironment environment) { |
| 26 | 35 | boolean result = rule.evaluate(environment); |
| 27 | 35 | if (result && ifTrue != null) { |
| 28 | 1 | ifTrue.execute(environment); |
| 29 | |
} |
| 30 | 35 | if (!result && ifFalse != null) { |
| 31 | 1 | ifFalse.execute(environment); |
| 32 | |
} |
| 33 | 35 | } |
| 34 | |
|
| 35 | |
} |