Package javax.validation.metadata

Examples of javax.validation.metadata.BeanDescriptor


  }

  @Test
  @SpecAssertion(section = "6.3", id = "f")
  public void testGetConstrainedMethodsTypesGETTERAndNON_GETTER() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    Set<MethodDescriptor> methodDescriptors = beanDescriptor.getConstrainedMethods(
        MethodType.GETTER,
        MethodType.NON_GETTER
    );

    List<String> actualMethodNames = new ArrayList<String>();
View Full Code Here


  }

  @Test
  @SpecAssertion(section = "6.3", id = "f")
  public void testGetConstrainedMethodsForUnconstrainedEntity() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
    Set<MethodDescriptor> methodDescriptors = beanDescriptor.getConstrainedMethods(
        MethodType.GETTER,
        MethodType.NON_GETTER
    );
    assertEquals( methodDescriptors.size(), 0, "We should get the empty set." );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "g")
  public void testGetConstraintsForNonExistingConstructorConstructor() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    ConstructorDescriptor constructorDescriptor = beanDescriptor.getConstraintsForConstructor(
        Short.class
    );
    assertNull( constructorDescriptor, "Descriptor should be null" );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "h")
  public void testGetConstrainedConstructors() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    Set<ConstructorDescriptor> constructorDescriptors = beanDescriptor.getConstrainedConstructors();

    Set<List<Class<?>>> actualParameterTypes = getParameterTypes( constructorDescriptors );

    @SuppressWarnings("unchecked")
    Set<List<Class<?>>> expectedParameterTypes = asSet(
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "h")
  public void testGetConstrainedConstructorsForUnconstrainedEntity() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
    Set<ConstructorDescriptor> constructorDescriptors = beanDescriptor.getConstrainedConstructors();
    assertEquals( constructorDescriptors.size(), 0, "We should get the empty set." );
  }
View Full Code Here

  private String validateMethodGetterName(PropertyDescriptor p) {
    return "validateProperty_get" + p.getPropertyName();
  }

  private void writeBeanDescriptor(SourceWriter sw) {
    BeanDescriptor beanDescriptor = beanHelper.getBeanDescriptor();

    // private final GwtBeanDescriptor <MyBean> beanDescriptor =
    sw.print("private final ");
    sw.print(GwtBeanDescriptor.class.getCanonicalName());
    sw.print("<" + beanHelper.getTypeCanonicalName() + ">");
    sw.println(" beanDescriptor = ");
    sw.indent();
    sw.indent();

    // GwtBeanDescriptorImpl.builder(Order.class)
    sw.print(GwtBeanDescriptorImpl.class.getCanonicalName());
    sw.println(".builder(" + beanHelper.getTypeCanonicalName() + ".class)");
    sw.indent();
    sw.indent();

    // .setConstrained(true)
    sw.println(".setConstrained(" + beanDescriptor.isBeanConstrained() + ")");

    int count = 0;
    for (ConstraintDescriptor<?> constraint : beanDescriptor.getConstraintDescriptors()) {
      if (areConstraintDescriptorGroupsValid(constraint)) {
        // .add(c0)
        sw.println(".add(" + constraintDescriptorVar("this", count) + ")");
        count++;
      }
    }

    // .put("myProperty", myProperty_pd)
    for (PropertyDescriptor p : beanDescriptor.getConstrainedProperties()) {
      sw.print(".put(\"");
      sw.print(p.getPropertyName());
      sw.print("\", ");
      sw.print(p.getPropertyName());
      sw.println("_pd)");
View Full Code Here

            return;
        }

        final Validator validator = validatorFactory.getValidator();

        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(beanValidationContext.getBeanType());

        String currentProperty = beanValidationContext.getCurrentProperty();

        if (currentProperty == null) return;

        PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(currentProperty);

        if (propertyDescriptor == null) return;

        for (final ConstraintDescriptor<?> descriptor : propertyDescriptor.getConstraintDescriptors())
        {
View Full Code Here

        if (currentProperty == null) return;
       
        Class<?> beanType = beanValidationContext.getBeanType();
        String[] path = currentProperty.split("\\.");
        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(beanType);
       
        for (int i = 1; i < path.length - 1; i++)
        {
            Class<?> constrainedPropertyClass = getConstrainedPropertyClass(beanDescriptor, path[i]);
            if (constrainedPropertyClass != null) {
                beanType = constrainedPropertyClass;
                beanDescriptor = validator.getConstraintsForClass(beanType);
            }
        }

        final String propertyName = path[path.length - 1];
        PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(propertyName);

        if (propertyDescriptor == null) return;

        final Set<ConstraintViolation<Object>> violations = validator.validateValue(
                (Class<Object>) beanType, propertyName,
View Full Code Here

        String valueProperty = (String) referenceProperty;

        // Initialize Bean Validation.
        ValidatorFactory validatorFactory = createValidatorFactory(context);
        javax.validation.Validator validator = createValidator(validatorFactory, context);
        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(valueBaseClass);
        if (!beanDescriptor.isBeanConstrained())
        {
            return;
        }
       
        // Note that validationGroupsArray was initialized when createValidator was called
View Full Code Here

                 Class<?> clazz,
                 ValidatorFactory factory,
                 Set<Class<?>> groups,
                 boolean activateNotNull,
                                 Dialect dialect) {
    final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz );
    //no bean level constraints can be applied, go to the properties

    for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) {
      Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() );
      boolean hasNotNull;
      if ( property != null ) {
        hasNotNull = applyConstraints(
            propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect
View Full Code Here

TOP

Related Classes of javax.validation.metadata.BeanDescriptor

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.