Package javax.validation.constraints

Examples of javax.validation.constraints.Size.min()


    protected Map<String, Object> transformMetaData(ConstraintDescriptor<Size> constraintDescriptor)
    {
        Map<String, Object> results = new HashMap<String, Object>();
        Size annotation = constraintDescriptor.getAnnotation();

        int minimum = annotation.min();

        if(minimum != 0)
        {
            results.put(CommonMetaDataKeys.MIN_LENGTH, minimum);
        }
View Full Code Here


    protected Map<String, Object> transformMetaData(ConstraintDescriptor<Size> constraintDescriptor)
    {
        Map<String, Object> results = new HashMap<String, Object>();
        Size annotation = constraintDescriptor.getAnnotation();

        int minimum = annotation.min();

        if(minimum != 0)
        {
            results.put(CommonMetaDataKeys.MIN_LENGTH, minimum);
        }
View Full Code Here

    boolean hasSize = false;
    for ( ConstraintDescriptor<?> desc : composingDescriptors ) {
      if ( desc.getAnnotation().annotationType().equals( Size.class ) ) {
        hasSize = true;
        Size sizeAnn = (Size) desc.getAnnotation();
        assertEquals( sizeAnn.min(), 5, "The min parameter should reflect the overridden parameter" );
        assertEquals(
            desc.getAttributes().get( "min" ),
            5,
            "The min parameter should reflect the overridden parameter"
        );
View Full Code Here

            // The annotated element size must be between the specified boundaries (included).
            Size size = (Size) annotation;
            if (size.min() > 0) {
                sb.append("required: true, \n");
            }
            sb.append("minlength: ").append(size.min()).append(",\n");
            sb.append("maxlength: ").append(size.max());
        } else if (annotation instanceof Size.List) {
            // Defines several @Size annotations on the same element
            throw new UnsupportedOperationException("Not implemented");
        }
View Full Code Here

            return true;
        } else if (annotation instanceof NotNull) {
            return true;
        } else if (annotation instanceof Size) {
            Size sizeAnnotation = (Size) annotation;
            return sizeAnnotation.min() > 0;
        }
        return false;
    }
}
View Full Code Here

                    editableValueHolder.setRequired(true);
                }
            }
            else if (constraint.annotationType().equals(Size.class)) {
                Size size = (Size) constraint;
                if (size.min() > 0) {
                    editableValueHolder.setRequired(true);
                }
            }
            else if (constraint.annotationType().equals(NotNull.class)) {
                editableValueHolder.setRequired(true);
View Full Code Here

            }
            property.addFacet(facet);
        }
        if (helper.isAnnotationPresent(element, Size.class)) {
            Size a = (Size) helper.getAnnotation(element, Size.class);
            final int min = a.min();
            final int max = a.max();
            if (min != 0 || max != Integer.MAX_VALUE) { // Fixes generation of an empty facet.
                if ("java.lang.String".equals(property.getType().getName())) { // @Size serves for both length facet and occurs restriction.
                    SizeFacet facet = new SizeFacet(min, max); // For minLength, maxLength.
                    property.addFacet(facet);
View Full Code Here

    Set<ConstraintDescriptor<?>> composingDescriptors = descriptor.getComposingConstraints();
    assertEquals( composingDescriptors.size(), 2, "Wrong number of composing constraints" );
    for ( ConstraintDescriptor<?> desc : composingDescriptors ) {
      if ( desc.getAnnotation().annotationType().equals( Size.class ) ) {
        Size sizeAnn = ( Size ) desc.getAnnotation();
        assertEquals( sizeAnn.min(), 5, "The min parameter should reflect the overriden parameter" );
        assertEquals(
            desc.getAttributes().get( "min" ), 5, "The min parameter should reflect the overriden parameter"
        );
      }
      else if ( desc.getAnnotation().annotationType().equals( NotNull.class ) ) {
View Full Code Here

    descriptor.setValue( "min", 5 );
    descriptor.setValue( "max", 10 );

    Size size = AnnotationFactory.create( descriptor );

    assertEquals( size.min(), 5, "Wrong parameter value" );
    assertEquals( size.max(), 10, "Wrong parameter value" );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void createAnnotationProxyMissingRequiredParameter() {
View Full Code Here

      params += ((DecimalMax) annotation).value();
    }

    if (annotation instanceof Size) {
      Size size = (Size) annotation;
      params += size.min() + ", " + size.max();
    }

    return params;
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.