Package javax.validation.constraints

Examples of javax.validation.constraints.Size


    }

    public void processConstraintDescriptor(ConstraintDescriptor cd) {
        //Size.class is understood by the tool
        if (cd.getAnnotation().annotationType().equals(Size.class)) {
            Size m = (Size) cd.getAnnotation();
//            System.out.println("size.max = " + m.max());  //read and use the metadata
        }
        for (Object composingCd : cd.getComposingConstraints()) {
            processConstraintDescriptor((ConstraintDescriptor) composingCd);
            //check composing constraints recursively
View Full Code Here


public class StringSizeMetaDataTransformer extends AbstractBeanValidationMetaDataTransformer<Size>
{
    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);
        }
        else
        {
            results.put(CommonMetaDataKeys.MIN_LENGTH_DEFAULT, minimum);
        }

        int maximum = annotation.max();
        if(maximum != Integer.MAX_VALUE)
        {
            results.put(CommonMetaDataKeys.MAX_LENGTH, maximum);
        }
        else
View Full Code Here

        // Not null on all validation groups so enable
        // DDL generation of Not Null Constraint
        prop.setNullable(false);
      }

      Size size = get(prop, Size.class);
      if (size != null) {
        if (size.max() < Integer.MAX_VALUE) {
          // explicitly specify a version column
          prop.setDbLength(size.max());
        }
      }
    }

    EmbeddedColumns columns = get(prop, EmbeddedColumns.class);
View Full Code Here

    if(aLength != null) {
      maxlen = aLength.max();
    }
    else {
      // try Size anno
      final Size aSize = m.getAnnotation(Size.class);
      if(aSize != null) {
        maxlen = aSize.max();
      }
    }

    if(rt == String.class) {
      maxlen = maxlen == -1 ? 255 : maxlen;
View Full Code Here

       
        Annotation constraint = constraintDescriptor.getAnnotation();
       
        if (!isMaxlenghtSet(input)) {
            if (constraint.annotationType().equals(Size.class)) {
                Size size = (Size) constraint;
                if (size.max() > 0) {
                    setMaxlength(input, size.max());
                }
            }
        }
       
        if (!editableValueHolder.isRequired()) {
View Full Code Here

public class StringSizeMetaDataTransformer extends AbstractBeanValidationMetaDataTransformer<Size>
{
    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);
        }
        else
        {
            results.put(CommonMetaDataKeys.MIN_LENGTH_DEFAULT, minimum);
        }

        int maximum = annotation.max();
        if(maximum != Integer.MAX_VALUE)
        {
            results.put(CommonMetaDataKeys.MAX_LENGTH, maximum);
        }
        else
View Full Code Here

    assertEquals( composingDescriptors.size(), 2, "Wrong number of composing constraints" );
    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

  @Override
  public void modify(FormComponent<?> component, ComponentTag tag, Size annotation)
  {
    if ("input".equalsIgnoreCase(tag.getName()))
    {
      Size size = (Size)annotation;
      tag.put("maxlen", size.max());
    }
  }
View Full Code Here

    }

    public void processConstraintDescriptor(ConstraintDescriptor<?> cd) {
        //Size.class is understood by the tool
        if (cd.getAnnotation().annotationType().equals(Size.class)) {
            @SuppressWarnings("unused")
            Size m = (Size) cd.getAnnotation();//what for?
        }
        for (ConstraintDescriptor<?> composingCd : cd.getComposingConstraints()) {
            //check composing constraints recursively
            processConstraintDescriptor(composingCd);
View Full Code Here

    assertEquals( composingDescriptors.size(), 2, "Wrong number of composing constraints" );
    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

TOP

Related Classes of javax.validation.constraints.Size

Copyright © 2018 www.massapicom. 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.