Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RuleExpressionResult |
|
| 1.1428571428571428;1.143 |
1 | /** | |
2 | * Copyright 2005-2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kew.rule; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.Collections; | |
20 | import java.util.List; | |
21 | ||
22 | import org.apache.commons.lang.builder.ToStringBuilder; | |
23 | ||
24 | /** | |
25 | * Result of a {@link RuleExpression} evaluation | |
26 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
27 | */ | |
28 | public class RuleExpressionResult { | |
29 | /** | |
30 | * The rule whose evaluation yielded this result | |
31 | */ | |
32 | private final Rule rule; | |
33 | /** | |
34 | * Whether the expression succeeded | |
35 | */ | |
36 | private final boolean success; | |
37 | /** | |
38 | * Any responsibilities generated from a successful evaluation | |
39 | */ | |
40 | private final List<org.kuali.rice.kew.api.rule.RuleResponsibility> responsibilities; | |
41 | ||
42 | /** | |
43 | * Constructs a rule expression result with a success indicator but no responsibilities | |
44 | * @param success whether the expression succeeded | |
45 | */ | |
46 | 0 | public RuleExpressionResult(Rule rule, boolean success) { |
47 | 0 | this.rule = rule; |
48 | 0 | this.success = success; |
49 | 0 | this.responsibilities = null; |
50 | 0 | } |
51 | ||
52 | /** | |
53 | * Constructs a rule expression result with both a success indicator and a list of responsibilities | |
54 | * @param success whether the expression succeeded | |
55 | * @param responsibilities any responsibilities generated from a successful evaluation | |
56 | */ | |
57 | 0 | public RuleExpressionResult(Rule rule, boolean success, List<org.kuali.rice.kew.api.rule.RuleResponsibility> responsibilities) { |
58 | 0 | this.rule = rule; |
59 | 0 | this.success = success; |
60 | 0 | this.responsibilities = responsibilities; |
61 | 0 | } |
62 | ||
63 | /** | |
64 | * Constructs a rule expression result with both a success indicator and a single responsibilities | |
65 | * @param success whether the expression succeeded | |
66 | * @param responsibility a single responsibility generated from a successful evaluation | |
67 | */ | |
68 | 0 | public RuleExpressionResult(Rule rule, boolean success, org.kuali.rice.kew.api.rule.RuleResponsibility responsibility) { |
69 | 0 | this.rule = rule; |
70 | 0 | this.success = success; |
71 | 0 | if (responsibility != null) { |
72 | 0 | responsibilities = Collections.singletonList(responsibility); |
73 | } else { | |
74 | 0 | responsibilities = null; |
75 | } | |
76 | 0 | } |
77 | ||
78 | /** | |
79 | * @return the rule that this expression result is associated with | |
80 | */ | |
81 | public Rule getRule() { | |
82 | 0 | return rule; |
83 | } | |
84 | ||
85 | /** | |
86 | * @return whether the evaluation was successful | |
87 | */ | |
88 | public boolean isSuccess() { | |
89 | 0 | return success; |
90 | } | |
91 | ||
92 | /** | |
93 | * @return any responsibilities generated from a successful evaluation | |
94 | */ | |
95 | public List<org.kuali.rice.kew.api.rule.RuleResponsibility> getResponsibilities() { | |
96 | 0 | return responsibilities; |
97 | } | |
98 | ||
99 | public String toString() { | |
100 | 0 | return new ToStringBuilder(this).append("rule", rule) |
101 | .append("success", success) | |
102 | .append("responsibilities", responsibilities).toString(); | |
103 | } | |
104 | } |