| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| RuleExpressionResult |
|
| 1.1428571428571428;1.143 |
| 1 | /* | |
| 2 | * Copyright 2007 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.List; | |
| 20 | ||
| 21 | import org.apache.commons.lang.builder.ToStringBuilder; | |
| 22 | ||
| 23 | /** | |
| 24 | * Result of a {@link RuleExpression} evaluation | |
| 25 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 26 | */ | |
| 27 | public class RuleExpressionResult { | |
| 28 | /** | |
| 29 | * The rule whose evaluation yielded this result | |
| 30 | */ | |
| 31 | private final Rule rule; | |
| 32 | /** | |
| 33 | * Whether the expression succeeded | |
| 34 | */ | |
| 35 | private final boolean success; | |
| 36 | /** | |
| 37 | * Any responsibilities generated from a successful evaluation | |
| 38 | */ | |
| 39 | private final List<RuleResponsibility> responsibilities; | |
| 40 | ||
| 41 | /** | |
| 42 | * Constructs a rule expression result with a success indicator but no responsibilities | |
| 43 | * @param success whether the expression succeeded | |
| 44 | */ | |
| 45 | 0 | public RuleExpressionResult(Rule rule, boolean success) { |
| 46 | 0 | this.rule = rule; |
| 47 | 0 | this.success = success; |
| 48 | 0 | this.responsibilities = null; |
| 49 | 0 | } |
| 50 | ||
| 51 | /** | |
| 52 | * Constructs a rule expression result with both a success indicator and a list of responsibilities | |
| 53 | * @param success whether the expression succeeded | |
| 54 | * @param responsibilities any responsibilities generated from a successful evaluation | |
| 55 | */ | |
| 56 | 0 | public RuleExpressionResult(Rule rule, boolean success, List<RuleResponsibility> responsibilities) { |
| 57 | 0 | this.rule = rule; |
| 58 | 0 | this.success = success; |
| 59 | 0 | this.responsibilities = responsibilities; |
| 60 | 0 | } |
| 61 | ||
| 62 | /** | |
| 63 | * Constructs a rule expression result with both a success indicator and a single responsibilities | |
| 64 | * @param success whether the expression succeeded | |
| 65 | * @param responsibility a single responsibility generated from a successful evaluation | |
| 66 | */ | |
| 67 | 0 | public RuleExpressionResult(Rule rule, boolean success, RuleResponsibility responsibility) { |
| 68 | 0 | this.rule = rule; |
| 69 | 0 | this.success = success; |
| 70 | 0 | if (responsibility != null) { |
| 71 | 0 | responsibilities = new ArrayList<RuleResponsibility>(); |
| 72 | 0 | responsibilities.add(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<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 | } |