001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.datadictionary.validation.constraint;
017    
018    import javax.xml.bind.annotation.XmlAccessType;
019    import javax.xml.bind.annotation.XmlAccessorType;
020    import javax.xml.bind.annotation.XmlElement;
021    import java.util.List;
022    
023    /**
024     * CaseConstraint is imposed only when a certain condition is met
025     *
026     * <p>For example, if the country attribute value is "USA",
027     * then a prerequisite constraint may be imposed that the 'State' attribute is non-null.</p>
028     *
029     * <p>
030     * This class is a direct copy of one that was in Kuali Student.</p>
031     * 
032     * @author Kuali Rice Team (rice.collab@kuali.org)
033     * @since 1.1
034     */
035    @XmlAccessorType(XmlAccessType.FIELD)
036    public class CaseConstraint extends BaseConstraint {
037            @XmlElement
038        protected List<WhenConstraint> whenConstraint;
039            @XmlElement
040            protected String propertyName;
041            @XmlElement
042            protected String operator;
043            @XmlElement
044            protected boolean caseSensitive;
045    
046        /**
047         * get the {@code WhenConstraint}'s defined by this case constraint
048         *
049         * @return a list of constraints, null if not initialized
050         */
051            public List<WhenConstraint> getWhenConstraint() {
052                    return whenConstraint;
053            }
054    
055        /**
056         * sets the {@code WhenConstraint}'s defined by this case constraint
057         *
058         * @param whenConstraint - the list of constraints
059         */
060            public void setWhenConstraint(List<WhenConstraint> whenConstraint) {
061                    this.whenConstraint = whenConstraint;
062            }
063    
064        /**
065         * gets the property name for the attribute to which the case constraint is applied to
066         *
067         * @return the property name
068         */
069            public String getPropertyName() {
070                    return propertyName;
071            }
072    
073        /**
074         * setter for property name
075         *
076         * @param propertyName a valid property name
077         */
078            public void setPropertyName(String propertyName) {
079                    this.propertyName = propertyName;
080            }
081    
082        /**
083         * specifies the kind of relationship to be checked between the actual value and the ones defined in the {@link #getWhenConstraint()}
084         *
085         * @see org.kuali.rice.krad.uif.UifConstants.CaseConstraintOperators
086         * @return an operator name
087         */
088            public String getOperator() {
089                    return operator;
090            }
091    
092        /**
093         * setter for the operator
094         *
095         * @see org.kuali.rice.krad.uif.UifConstants.CaseConstraintOperators
096         * @param operator
097         */
098            public void setOperator(String operator) {
099                    this.operator = operator;
100            }
101    
102        /**
103         * checks whether string comparison will be carried out in a case sensitive fashion
104         *
105         * @return true if string comparison is case sensitive, false if not
106         */
107        public boolean isCaseSensitive() {
108            return caseSensitive;
109        }
110    
111        /**
112         * setter for case sensitive
113         *
114         * @param caseSensitive - the case sensitive value to set
115         */
116        public void setCaseSensitive(boolean caseSensitive) {
117            this.caseSensitive = caseSensitive;
118        }
119    }