private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; String checkConstraint = col.getQuotedName( dialect ) + "<=" + max; applySQLCheck( col, checkConstraint ); } } } }
if ("integer".equals(property.getType()) || "number".equals(property.getType())) { Max max = (Max) annos.get("javax.validation.constraints.Max"); property.setMaximum(new BigDecimal(max.value()));
spinner.setMax(max.value());
@Override public final void initialize(Max constraintAnnotation) { max = constraintAnnotation.value(); }
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings( "unchecked" ) ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + "<=" + max ); } }
maxValue = maxAnnotation.value();
/** * Checks whether a given value is lesser than given max value or not * * @param validationObject * @param annotate * @return */ private boolean validateMaxValue(Object validationObject, Annotation annotate) { if (checkNullObject(validationObject)) { return true; } Long maxValue = ((Max) annotate).value(); if (checkvalidDigitTypes(validationObject.getClass())) { if ((NumberUtils.toLong(toString(validationObject))) > maxValue) { throwValidationException(((Max) annotate).message()); } } return true; }
@Override public void initialize(Max maxValue) { this.maxValue = maxValue.value(); }
@Override public boolean isValid(final Number value, final ConstraintValidatorContext context) { return value == null || value.longValue() <= max.value(); } }
@Override public void initialize(Max maxValue) { this.maxValue = BigDecimal.valueOf( maxValue.value() ); }
@Override public void configure(Max max) { this.max = max.value(); setMessage(max.message()); }
public Long max() { final Max max = mMethod.getAnnotation(Max.class); if (max != null) { return max.value(); } final long[] minMax = minMaxFromDataType(attribute().dataType()); return minMax == null ? null : minMax[1]; }
@Override public Double getNumberMaximum(BeanProperty prop) { Max maxAnnotation = prop.getAnnotation(Max.class); if (maxAnnotation != null) { return (double) maxAnnotation.value(); } DecimalMax decimalMaxAnnotation = prop.getAnnotation(DecimalMax.class); return decimalMaxAnnotation != null ? new BigDecimal(decimalMaxAnnotation.value()).doubleValue() : null; }
@Override public Double getNumberMaximum(BeanProperty prop) { Max maxAnnotation = prop.getAnnotation(Max.class); if (maxAnnotation != null) { return (double) maxAnnotation.value(); } DecimalMax decimalMaxAnnotation = prop.getAnnotation(DecimalMax.class); return decimalMaxAnnotation != null ? new BigDecimal(decimalMaxAnnotation.value()).doubleValue() : null; }
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); Column col = (Column) property.getColumnIterator().next(); String checkConstraint = col.getQuotedName(dialect) + "<=" + max; applySQLCheck( col, checkConstraint ); } }
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); Column col = (Column) property.getColumnIterator().next(); String checkConstraint = col.getQuotedName(dialect) + "<=" + max; applySQLCheck( col, checkConstraint ); } }
private static void applyMax(PersistentAttributeMapping property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") final ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; final long max = maxConstraint.getAnnotation().value(); final Column col = getColumn( property ); final String checkConstraint = col.getQuotedName(dialect) + "<=" + max; applySQLCheck( col, checkConstraint ); } }
private void appendMaxValidator(SourceWriter w, JField field) { Max maxAnnotation = field.getAnnotation(Max.class); if (maxAnnotation != null) { w.println(", new MaxValidator(\"%s\", %s)", maxAnnotation.message(), maxAnnotation.value()); } }
private void appendMaxValidator(SourceWriter w, JField field) { Max maxAnnotation = field.getAnnotation(Max.class); if (maxAnnotation != null) { w.println(", new MaxValidator(\"%s\", %s)", maxAnnotation.message(), maxAnnotation.value()); } }
@Test public void testFindAnnotationMethod() { assertEquals(3l, ReflectionHelper.findAnnotation(childABar, Min.class).value()); assertNull(ReflectionHelper.findAnnotation(childABar, Max.class)); assertEquals(4l, ReflectionHelper.findAnnotation(childAFoo, Max.class).value()); }