Package javax.validation.metadata

Examples of javax.validation.metadata.BeanDescriptor


  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() + ")");

    for (int count = 0; count < beanDescriptor.getConstraintDescriptors().size(); count++) {
      // .add(c0)
      sw.println(".add(" + constraintDescriptorVar("this", 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


        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

        this.methodInfo = methodInfo;
        this.methodValidator = methodValidator;
    }

    public boolean accepts(ResourceMethod method) {
        BeanDescriptor bean = methodValidator.getConstraintsForClass(method.getResource().getType());
        MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getMethod().getName(), method.getMethod().getParameterTypes());
        return descriptor != null && descriptor.hasConstrainedParameters();
    }
View Full Code Here

    if (method.getParameterTypes().length == 0) {
      logger.debug("method {} has no parameters, skipping", controllerMethod);
      return false;
    }

    BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
    MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
    return descriptor != null && descriptor.hasConstrainedParameters();
  }
View Full Code Here

    Method method = controllerMethod.getMethod();
    if (method.getParameterTypes().length == 0) {
      logger.debug("method {} has no parameters, skipping", controllerMethod);
      return false;
    }
    BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
    if(bean == null) {
      return false;
    }
    MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
    return descriptor != null && descriptor.hasConstrainedParameters();
  }
View Full Code Here

        return Collections.emptySet();
    }

    public static ElementDescriptor getElementDescriptor(Class targetClass, String property)
    {
        BeanDescriptor beanDescriptor = ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory()
                .getValidator().getConstraintsForClass(targetClass);

        return beanDescriptor.getConstraintsForProperty(property);
    }
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

   
    String currentProperty = beanValidationContext.getCurrentProperty();
   
    if(currentProperty == null) return;
   
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass(beanValidationContext.getBeanType());
   
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(currentProperty);
   
    if(propertyDescriptor == null) return;
   
    final Set<ConstraintViolation<Object>> violations = validator.validateValue(
            (Class<Object>) beanValidationContext.getBeanType(), currentProperty,
View Full Code Here

                uiComponent.getClientId(facesContext));
    }

    ElementDescriptor getDescriptorFor(Class targetClass, String property)
    {
        BeanDescriptor beanDescriptor = ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory()
                .getValidator().getConstraintsForClass(targetClass);

        return beanDescriptor.getConstraintsForProperty(property);
    }
View Full Code Here

                 PersistentClass persistentClass,
                 Class<?> clazz,
                 ValidatorFactory factory,
                 Set<Class<?>> groups,
                 boolean activateNotNull) {
    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
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.