javax.validation.constraints.Max.value()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中javax.validation.constraints.Max.value()方法的一些代码示例,展示了Max.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Max.value()方法的具体详情如下:
包路径:javax.validation.constraints.Max
类名称:Max
方法名:value

Max.value介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

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 );
      }
    }
  }
}

代码示例来源:origin: swagger-api/swagger-core

if ("integer".equals(property.getType()) || "number".equals(property.getType())) {
  Max max = (Max) annos.get("javax.validation.constraints.Max");
  property.setMaximum(new BigDecimal(max.value()));

代码示例来源:origin: primefaces/primefaces

spinner.setMax(max.value());

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public final void initialize(Max constraintAnnotation) {
 max = constraintAnnotation.value();
}

代码示例来源:origin: org.hibernate/hibernate-annotations

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 );
  }
}

代码示例来源:origin: benas/random-beans

maxValue = maxAnnotation.value();

代码示例来源:origin: Impetus/Kundera

/**
 * 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;
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator

@Override
public void initialize(Max maxValue) {
  this.maxValue = maxValue.value();
}

代码示例来源:origin: org.minijax/minijax-validator

@Override
  public boolean isValid(final Number value, final ConstraintValidatorContext context) {
    return value == null || value.longValue() <= max.value();
  }
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator

@Override
public void initialize(Max maxValue) {
  this.maxValue = BigDecimal.valueOf( maxValue.value() );
}

代码示例来源:origin: stackoverflow.com

@Override
 public void configure(Max max) {
   this.max = max.value();
   setMessage(max.message());
 }

代码示例来源:origin: org.glassfish.main.common/amx-core

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];
}

代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jsonSchema

@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;
}

代码示例来源:origin: FasterXML/jackson-module-jsonSchema

@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;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

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 );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

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 );
  }
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

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 );
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

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());
  }
}

代码示例来源:origin: Putnami/putnami-web-toolkit

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());
  }
}

代码示例来源:origin: cloudera/cm_ext

@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());
}

相关文章