| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| MustOccurConstraint |
|
| 1.0;1 |
| 1 | package org.kuali.rice.krad.datadictionary.validation.constraint; | |
| 2 | ||
| 3 | import javax.xml.bind.annotation.XmlAccessType; | |
| 4 | import javax.xml.bind.annotation.XmlAccessorType; | |
| 5 | import javax.xml.bind.annotation.XmlElement; | |
| 6 | import java.util.List; | |
| 7 | ||
| 8 | /** | |
| 9 | * Must occur constraints are constraints that indicate some range of acceptable valid results. So a must occur constraint | |
| 10 | * might indicate that between 1 and 3 prequisite constraints must be valid. For example, on a person object, it might be | |
| 11 | * that one of three fields must be filled in: | |
| 12 | * | |
| 13 | * 1. username | |
| 14 | * 2. email | |
| 15 | * 3. phone number | |
| 16 | * | |
| 17 | * By imposing a must occur constraint on the person object iself, and setting three prequisite constraints below it, with a min of 1 | |
| 18 | * and a max of 3, this requirement can be enforced. | |
| 19 | * | |
| 20 | * A more complicated example might be that a US address is only valid if it provides either: | |
| 21 | * (a) a city and state, or | |
| 22 | * (b) a postal code | |
| 23 | * | |
| 24 | * To enforce this, a single must occur constraint would have two children: (1) a prequisite constraint on postal code, and (2) a must occur constraint | |
| 25 | * with two child prequisite constraints, on city and state, respectively. By setting min=1/max=2 at the top must occur constraint, | |
| 26 | * and min=2/max=2 at the leaf constraint, this requirement can be enforced. | |
| 27 | * | |
| 28 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 29 | * @since 1.1 | |
| 30 | */ | |
| 31 | @XmlAccessorType(XmlAccessType.FIELD) | |
| 32 | 10 | public class MustOccurConstraint extends BaseConstraint { |
| 33 | ||
| 34 | @XmlElement | |
| 35 | private List<PrerequisiteConstraint> prerequisiteConstraints; | |
| 36 | @XmlElement | |
| 37 | private List<MustOccurConstraint> mustOccurConstraints; | |
| 38 | @XmlElement | |
| 39 | private Integer min; | |
| 40 | @XmlElement | |
| 41 | private Integer max; | |
| 42 | ||
| 43 | public List<PrerequisiteConstraint> getPrerequisiteConstraints() { | |
| 44 | 6 | return prerequisiteConstraints; |
| 45 | } | |
| 46 | ||
| 47 | public void setPrerequisiteConstraints(List<PrerequisiteConstraint> prerequisiteConstraints) { | |
| 48 | 10 | this.prerequisiteConstraints = prerequisiteConstraints; |
| 49 | 10 | } |
| 50 | ||
| 51 | public List<MustOccurConstraint> getMustOccurConstraints() { | |
| 52 | 6 | return mustOccurConstraints; |
| 53 | } | |
| 54 | ||
| 55 | public void setMustOccurConstraints(List<MustOccurConstraint> occurs) { | |
| 56 | 5 | this.mustOccurConstraints = occurs; |
| 57 | 5 | } |
| 58 | ||
| 59 | public Integer getMin() { | |
| 60 | 12 | return min; |
| 61 | } | |
| 62 | ||
| 63 | public void setMin(Integer min) { | |
| 64 | 10 | this.min = min; |
| 65 | 10 | } |
| 66 | ||
| 67 | public Integer getMax() { | |
| 68 | 12 | return max; |
| 69 | } | |
| 70 | ||
| 71 | public void setMax(Integer max) { | |
| 72 | 10 | this.max = max; |
| 73 | 10 | } |
| 74 | } |