View Javadoc

1   /**
2    * Copyright 2005-2013 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.krad.datadictionary.validation.constraint;
17  
18  import org.kuali.rice.core.api.uif.DataType;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22  
23  /**
24   * A simple constraint stores 'basic' constraints for a field.  This constraint is meant to be used as a
25   * constraint for WhenConstraints in CaseConstraint, and is also used internally in InputField.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  @BeanTags({@BeanTag(name = "simpleContraint-bean", parent = "SimpleConstraint"),
30          @BeanTag(name = "requiredConstraint-bean", parent = "RequiredConstraint")})
31  public class SimpleConstraint extends BaseConstraint implements ExistenceConstraint, RangeConstraint, LengthConstraint {
32  
33      private Boolean required;
34      private Integer maxLength;
35      private Integer minLength;
36      private String exclusiveMin;
37      private String inclusiveMax;
38  
39      //Don't know if we will support min/max occurs at this time
40      private Integer minOccurs;
41      private Integer maxOccurs;
42  
43      private DataType dataType;
44  
45      /**
46       * If true the field is required
47       *
48       * @return the required
49       */
50      @BeanTagAttribute(name = "required")
51      public Boolean getRequired() {
52          return this.required;
53      }
54  
55      /**
56       * @param required the required to set
57       */
58      public void setRequired(Boolean required) {
59          this.required = required;
60      }
61  
62      /**
63       * @see org.kuali.rice.krad.datadictionary.validation.constraint.ExistenceConstraint#isRequired()
64       */
65      @Override
66      public Boolean isRequired() {
67          return getRequired();
68      }
69  
70      /**
71       * The maximum amount of characters this field's value can be
72       *
73       * @return the maxLength
74       */
75      @BeanTagAttribute(name = "maxLength")
76      public Integer getMaxLength() {
77          return this.maxLength;
78      }
79  
80      /**
81       * @param maxLength the maxLength to set
82       */
83      public void setMaxLength(Integer maxLength) {
84          this.maxLength = maxLength;
85      }
86  
87      /**
88       * The minimum amount of characters this field's value has to be
89       *
90       * @return the minLength
91       */
92      @BeanTagAttribute(name = "minLength")
93      public Integer getMinLength() {
94          return this.minLength;
95      }
96  
97      /**
98       * @param minLength the minLength to set
99       */
100     public void setMinLength(Integer minLength) {
101         this.minLength = minLength;
102     }
103 
104     /**
105      * Exclusive minimum value for this field
106      *
107      * @return the exclusiveMin
108      */
109     @BeanTagAttribute(name = "exclusiveMin")
110     public String getExclusiveMin() {
111         return this.exclusiveMin;
112     }
113 
114     /**
115      * @param exclusiveMin the exclusiveMin to set
116      */
117     public void setExclusiveMin(String exclusiveMin) {
118         this.exclusiveMin = exclusiveMin;
119     }
120 
121     /**
122      * Inclusive max value for this field
123      *
124      * @return the inclusiveMax
125      */
126     @BeanTagAttribute(name = "inclusiveMax")
127     public String getInclusiveMax() {
128         return this.inclusiveMax;
129     }
130 
131     /**
132      * @param inclusiveMax the inclusiveMax to set
133      */
134     public void setInclusiveMax(String inclusiveMax) {
135         this.inclusiveMax = inclusiveMax;
136     }
137 
138     /**
139      * The minimum amount of items in this fields list of values - not yet used/do not use
140      *
141      * @return the minOccurs
142      */
143     @BeanTagAttribute(name = "minOccurs")
144     public Integer getMinOccurs() {
145         return this.minOccurs;
146     }
147 
148     /**
149      * @param minOccurs the minOccurs to set
150      */
151     public void setMinOccurs(Integer minOccurs) {
152         this.minOccurs = minOccurs;
153     }
154 
155     /**
156      * The maximum amount of items in this field's list of values - not yet used/do not use
157      *
158      * @return the maxOccurs
159      */
160     @BeanTagAttribute(name = "maxOccurs")
161     public Integer getMaxOccurs() {
162         return this.maxOccurs;
163     }
164 
165     /**
166      * @param maxOccurs the maxOccurs to set
167      */
168     public void setMaxOccurs(Integer maxOccurs) {
169         this.maxOccurs = maxOccurs;
170     }
171 
172     @BeanTagAttribute(name = "dataType", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
173     public DataType getDataType() {
174         return dataType;
175     }
176 
177     public void setDataType(DataType dataType) {
178         this.dataType = dataType;
179     }
180 }
181