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