001 /** 002 * Copyright 2005-2014 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 org.kuali.rice.core.api.uif.DataType; 019 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 020 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 021 import org.kuali.rice.krad.datadictionary.parse.BeanTags; 022 023 /** 024 * A simple constraint stores 'basic' constraints for a field. This constraint is meant to be used as a 025 * constraint for WhenConstraints in CaseConstraint, and is also used internally in InputField. 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029 @BeanTags({@BeanTag(name = "simpleContraint-bean", parent = "SimpleConstraint"), 030 @BeanTag(name = "requiredConstraint-bean", parent = "RequiredConstraint")}) 031 public class SimpleConstraint extends BaseConstraint implements ExistenceConstraint, RangeConstraint, LengthConstraint { 032 033 private Boolean required; 034 private Integer maxLength; 035 private Integer minLength; 036 private String exclusiveMin; 037 private String inclusiveMax; 038 039 //Don't know if we will support min/max occurs at this time 040 private Integer minOccurs; 041 private Integer maxOccurs; 042 043 private DataType dataType; 044 045 /** 046 * If true the field is required 047 * 048 * @return the required 049 */ 050 @BeanTagAttribute(name = "required") 051 public Boolean getRequired() { 052 return this.required; 053 } 054 055 /** 056 * @param required the required to set 057 */ 058 public void setRequired(Boolean required) { 059 this.required = required; 060 } 061 062 /** 063 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ExistenceConstraint#isRequired() 064 */ 065 @Override 066 public Boolean isRequired() { 067 return getRequired(); 068 } 069 070 /** 071 * The maximum amount of characters this field's value can be 072 * 073 * @return the maxLength 074 */ 075 @BeanTagAttribute(name = "maxLength") 076 public Integer getMaxLength() { 077 return this.maxLength; 078 } 079 080 /** 081 * @param maxLength the maxLength to set 082 */ 083 public void setMaxLength(Integer maxLength) { 084 this.maxLength = maxLength; 085 } 086 087 /** 088 * The minimum amount of characters this field's value has to be 089 * 090 * @return the minLength 091 */ 092 @BeanTagAttribute(name = "minLength") 093 public Integer getMinLength() { 094 return this.minLength; 095 } 096 097 /** 098 * @param minLength the minLength to set 099 */ 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