| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ValidationRule |
|
| 3.5;3.5 |
| 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.krms.impl.validation; | |
| 17 | ||
| 18 | import org.kuali.rice.krms.framework.engine.Action; | |
| 19 | import org.kuali.rice.krms.framework.engine.BasicRule; | |
| 20 | import org.kuali.rice.krms.framework.engine.Proposition; | |
| 21 | import org.kuali.rice.krms.framework.type.ValidationRuleType; | |
| 22 | ||
| 23 | import java.util.List; | |
| 24 | ||
| 25 | /** | |
| 26 | * | |
| 27 | * A {@link org.kuali.rice.krms.framework.engine.Rule} that executes a {@link org.kuali.rice.krms.framework.engine.Action} when the {@link Proposition} is false, | |
| 28 | * as opposed to {@link BasicRule} which executes its action when the proposition is true. | |
| 29 | * | |
| 30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 31 | */ | |
| 32 | public class ValidationRule extends BasicRule { | |
| 33 | 0 | private ValidationRuleType type = null; |
| 34 | ||
| 35 | public ValidationRule(ValidationRuleType type, String name, Proposition proposition, List<Action> actions) { | |
| 36 | 0 | super(name, proposition, actions); |
| 37 | 0 | if (type == null) throw new IllegalArgumentException("type must not be null"); |
| 38 | 0 | this.type = type; |
| 39 | 0 | } |
| 40 | ||
| 41 | @Override | |
| 42 | protected boolean shouldExecuteAction(boolean ruleExecutionResult) { | |
| 43 | 0 | if (type == null || type.equals(ValidationRuleType.VALID)) { |
| 44 | 0 | return !ruleExecutionResult; |
| 45 | } | |
| 46 | 0 | return ruleExecutionResult; |
| 47 | } | |
| 48 | } |