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 org.kuali.rice.core.api.uif.DataType; 019 020import javax.xml.bind.annotation.XmlAccessType; 021import javax.xml.bind.annotation.XmlAccessorType; 022import javax.xml.bind.annotation.XmlElement; 023 024/** 025 * A simple constraint stores 'basic' constraints for a field. This constraint is meant to be used as a 026 * constraint for WhenConstraints in CaseConstraint, and is also used internally in InputField. 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030@XmlAccessorType(XmlAccessType.FIELD) 031public class SimpleConstraint extends BaseConstraint implements ExistenceConstraint, RangeConstraint, LengthConstraint{ 032 033 @XmlElement 034 private Boolean required; 035 036 @XmlElement 037 private Integer maxLength; 038 039 @XmlElement 040 private Integer minLength; 041 042 @XmlElement 043 protected String exclusiveMin; 044 045 @XmlElement 046 protected String inclusiveMax; 047 048 //Don't know if we will support min/max occurs at this time 049 @XmlElement 050 private Integer minOccurs; 051 052 @XmlElement 053 private Integer maxOccurs; 054 055 private DataType dataType; 056 057 /** 058 * If true the field is required 059 * @return the required 060 */ 061 public Boolean getRequired() { 062 return this.required; 063 } 064 065 /** 066 * @param required the required to set 067 */ 068 public void setRequired(Boolean required) { 069 this.required = required; 070 } 071 072 /** 073 * The maximum amount of characters this field's value can be 074 * @return the maxLength 075 */ 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 * @return the minLength 090 */ 091 public Integer getMinLength() { 092 return this.minLength; 093 } 094 095 /** 096 * @param minLength the minLength to set 097 */ 098 public void setMinLength(Integer minLength) { 099 this.minLength = minLength; 100 } 101 102 /** 103 * Exclusive minimum value for this field 104 * @return the exclusiveMin 105 */ 106 public String getExclusiveMin() { 107 return this.exclusiveMin; 108 } 109 110 /** 111 * @param exclusiveMin the exclusiveMin to set 112 */ 113 public void setExclusiveMin(String exclusiveMin) { 114 this.exclusiveMin = exclusiveMin; 115 } 116 117 /** 118 * Inclusive max value for this field 119 * @return the inclusiveMax 120 */ 121 public String getInclusiveMax() { 122 return this.inclusiveMax; 123 } 124 125 /** 126 * @param inclusiveMax the inclusiveMax to set 127 */ 128 public void setInclusiveMax(String inclusiveMax) { 129 this.inclusiveMax = inclusiveMax; 130 } 131 132 /** 133 * The minimum amount of items in this fields list of values - not yet used/do not use 134 * @return the minOccurs 135 */ 136 public Integer getMinOccurs() { 137 return this.minOccurs; 138 } 139 140 /** 141 * @param minOccurs the minOccurs to set 142 */ 143 public void setMinOccurs(Integer minOccurs) { 144 this.minOccurs = minOccurs; 145 } 146 147 /** 148 * The maximum amount of items in this field's list of values - not yet used/do not use 149 * @return the maxOccurs 150 */ 151 public Integer getMaxOccurs() { 152 return this.maxOccurs; 153 } 154 155 /** 156 * @param maxOccurs the maxOccurs to set 157 */ 158 public void setMaxOccurs(Integer maxOccurs) { 159 this.maxOccurs = maxOccurs; 160 } 161 162 163 /** 164 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ExistenceConstraint#isRequired() 165 */ 166 @Override 167 public Boolean isRequired() { 168 return getRequired(); 169 } 170 171 public DataType getDataType() { 172 return dataType; 173 } 174 175 public void setDataType(DataType dataType) { 176 this.dataType = dataType; 177 } 178} 179