001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.krad.datadictionary.validation.constraint;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import java.util.ArrayList;
021import java.util.List;
022
023/**
024 * A when constraint is a child of a case constraint. It provides a specific additional constraint that should be processed when 
025 * the condition itself is true. 
026 * 
027 * So a case constraint on country, might have a when constraint with value='USA', and another with value='Canada'. Each of these
028 * when constraints would define a constraint of their own that would only be processed when the country was USA, or when the country 
029 * was Canada. 
030 * 
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 * @since 1.1
033 */
034@XmlAccessorType(XmlAccessType.FIELD)
035public class WhenConstraint implements Constraint {
036        protected List<Object> values;
037        protected String valuePath;
038        protected Constraint constraint;
039
040        public List<Object> getValues() {
041                return values;
042        }
043
044        public void setValues(List<Object> values) {
045        this.values = values;
046    }
047
048    public void setValue(Object value) {            
049            values = new ArrayList<Object>();
050            values.add(value);
051        }
052
053        public String getValuePath() {
054                return valuePath;
055        }
056
057        public void setValuePath(String valuePath) {
058                this.valuePath = valuePath;
059        }
060
061        public Constraint getConstraint() {
062                return constraint;
063        }
064
065        public void setConstraint(Constraint constraint) {
066                this.constraint = constraint;
067        }
068}