private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; int max = sizeConstraint.getAnnotation().max(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); Column col = (Column) selectable; if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } } }
if ("integer".equals(property.getType()) || "number".equals(property.getType())) { property.setMinimum(new BigDecimal(size.min())); property.setMaximum(new BigDecimal(size.max())); } else if (property instanceof StringSchema) { StringSchema sp = (StringSchema) property; sp.minLength(new Integer(size.min())); sp.maxLength(new Integer(size.max())); } else if (property instanceof ArraySchema) { ArraySchema sp = (ArraySchema) property; sp.setMinItems(size.min()); sp.setMaxItems(size.max());
@Override public final void initialize(Size annotation) { if (!(annotation.min() >= 0)) { throw new IllegalArgumentException( "@Size.min must be a nonnegative nubmer"); } if (!(annotation.max() >= 0)) { throw new IllegalArgumentException( "@Size.max must be a nonnegative nubmer"); } if (!(annotation.min() <= annotation.max())) { throw new IllegalArgumentException( "@Size.min must be less than or equal to @Size.max"); } min = annotation.min(); max = annotation.max(); }
@Override public Randomizer<?> getRandomizer(Field field) { Class<?> fieldType = field.getType(); Size sizeAnnotation = ReflectionUtils .getAnnotation(field, Size.class); final int min = sizeAnnotation.min(); final int max = sizeAnnotation.max(); if (fieldType.equals(String.class)) { return new StringRandomizer(charset, min, max, random.nextLong()); } return null; } }
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = ( ConstraintDescriptor<Size> ) descriptor; int max = sizeConstraint.getAnnotation().max(); Column col = ( Column ) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } }
int maxSize = ((Size) annotate).max(); if (validationObject != null)
@Override public boolean isValid(final Object value, final ConstraintValidatorContext context) { if (value == null) { return true; } final int length = Array.getLength(value); return length >= size.min() && length <= size.max(); } }
@Override public boolean isValid(final Map<?, ?> value, final ConstraintValidatorContext context) { return value == null || (value.size() >= size.min() && value.size() <= size.max()); } }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
@Override public void initialize(Size parameters) { min = parameters.min(); max = parameters.max(); validateParameters(); }
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; int max = sizeConstraint.getAnnotation().max(); Column col = (Column) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } }
private static void applySize(PersistentAttributeMapping property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") final ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; final int max = sizeConstraint.getAnnotation().max(); final Column col = getColumn( property ); if ( max < Integer.MAX_VALUE ) { col.setLength( (long) max ); } } }
@Override public void modify(FormComponent<?> component, ComponentTag tag, Size annotation) { if (hasLengthAttribute(tag.getName())) { tag.put("maxlength", annotation.max()); if (annotation.min() > 0) { tag.put("minlength", annotation.min()); } } }