use of org.grails.validation.MaxSizeConstraint in project grails-core by grails.
the class ConstrainedProperty method setMaxSize.
/**
* @param maxSize The maxSize to set.
*/
public void setMaxSize(Integer maxSize) {
Constraint c = appliedConstraints.get(MAX_SIZE_CONSTRAINT);
if (c == null) {
c = new MaxSizeConstraint();
c.setOwningClass(owningClass);
c.setPropertyName(propertyName);
appliedConstraints.put(MAX_SIZE_CONSTRAINT, c);
}
c.setParameter(maxSize);
}
use of org.grails.validation.MaxSizeConstraint in project grails-core by grails.
the class ConstrainedProperty method getMaxSize.
/**
* @return Returns the maxSize.
*/
@Override
public Integer getMaxSize() {
Integer maxSize = null;
MaxSizeConstraint maxSizeConstraint = (MaxSizeConstraint) appliedConstraints.get(MAX_SIZE_CONSTRAINT);
SizeConstraint sizeConstraint = (SizeConstraint) appliedConstraints.get(SIZE_CONSTRAINT);
if (maxSizeConstraint != null || sizeConstraint != null) {
int maxSizeConstraintValue = maxSizeConstraint == null ? Integer.MAX_VALUE : maxSizeConstraint.getMaxSize();
int sizeConstraintHighValue = sizeConstraint == null ? Integer.MAX_VALUE : sizeConstraint.getRange().getToInt();
maxSize = Math.min(maxSizeConstraintValue, sizeConstraintHighValue);
}
return maxSize;
}
Aggregations