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.data.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 private static final long serialVersionUID = -5988843786798202907L; 033 034 private Boolean required; 035 private Integer maxLength; 036 private Integer minLength; 037 private String exclusiveMin; 038 private String inclusiveMax; 039 040 //Don't know if we will support min/max occurs at this time 041 private Integer minOccurs; 042 private Integer maxOccurs; 043 044 private DataType dataType; 045 046 /** 047 * If true the field is required 048 * 049 * @return the required 050 */ 051 @BeanTagAttribute(name = "required") 052 public Boolean getRequired() { 053 return this.required; 054 } 055 056 /** 057 * @param required the required to set 058 */ 059 public void setRequired(Boolean required) { 060 this.required = required; 061 } 062 063 /** 064 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ExistenceConstraint#isRequired() 065 */ 066 @Override 067 public Boolean isRequired() { 068 return getRequired(); 069 } 070 071 /** 072 * The maximum amount of characters this field's value can be 073 * 074 * @return the maxLength 075 */ 076 @BeanTagAttribute(name = "maxLength") 077 public Integer getMaxLength() { 078 return this.maxLength; 079 } 080 081 /** 082 * @param maxLength the maxLength to set 083 */ 084 public void setMaxLength(Integer maxLength) { 085 this.maxLength = maxLength; 086 } 087 088 /** 089 * The minimum amount of characters this field's value has to be 090 * 091 * @return the minLength 092 */ 093 @BeanTagAttribute(name = "minLength") 094 public Integer getMinLength() { 095 return this.minLength; 096 } 097 098 /** 099 * @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