Package javax.validation.metadata

Examples of javax.validation.metadata.BeanDescriptor.findConstraints()


    @Override
    public List<ConstraintViolation> validateClassConstraint(Object bean) {
        final List<ConstraintViolation> list = new LinkedList<ConstraintViolation>();
        if (validator != null && bean != null) {
            BeanDescriptor beanDescriptor = validator.getConstraintsForClass(bean.getClass());
            Set<ConstraintDescriptor<?>> classLevelConstraints = beanDescriptor.findConstraints().declaredOn(ElementType.TYPE).getConstraintDescriptors();
            Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
            for (ConstraintViolation constraintViolation : constraintViolations) {
                if (classLevelConstraints.contains(constraintViolation.getConstraintDescriptor())) {
                    list.add(constraintViolation);
                }
View Full Code Here


   
    //create empty constraint violation set
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
   
    //validate class level properties
    for(ConstraintDescriptor<?> descriptor : bean.findConstraints().declaredOn(ElementType.TYPE).unorderedAndMatchingGroups(groups).getConstraintDescriptors()) {
      violations.addAll(this.validateConstraint((Class<T>)object.getClass(), descriptor, object));
    }
   
    //validate each constrained property individually
    for(PropertyDescriptor property : bean.getConstrainedProperties()) {
View Full Code Here

    }

    private List<ConstraintViolation> getConstraintViolation(Object bean) {
        final List<ConstraintViolation> list = new LinkedList<ConstraintViolation>();
        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(bean.getClass());
        Set<ConstraintDescriptor<?>> classLevelConstraints = beanDescriptor.findConstraints().declaredOn(ElementType.TYPE).getConstraintDescriptors();
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
        for (ConstraintViolation constraintViolation : constraintViolations) {
            if (classLevelConstraints.contains(constraintViolation.getConstraintDescriptor())) {
                list.add(constraintViolation);
            }
View Full Code Here

  @Override
  public List<ConstraintViolation> validateClassConstraint(Object bean) {
    final List<ConstraintViolation> list = new LinkedList<ConstraintViolation>();
    if (validator != null && bean != null) {
      BeanDescriptor beanDescriptor = validator.getConstraintsForClass(bean.getClass());
      Set<ConstraintDescriptor<?>> classLevelConstraints = beanDescriptor.findConstraints().declaredOn(ElementType.TYPE).getConstraintDescriptors();
      Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
      for (ConstraintViolation constraintViolation : constraintViolations) {
        if (classLevelConstraints.contains(constraintViolation.getConstraintDescriptor())) {
          list.add(constraintViolation);
        }
View Full Code Here

    BeanDescriptor beanDescriptor = getValidator().getConstraintsForClass( CustomerRepository.class );

    Set<ConstraintDescriptor<?>> constraintDescriptors = beanDescriptor.getConstraintDescriptors();
    assertEquals( constraintDescriptors.size(), 1, "Only the class-level @ScriptAssert is expected." );

    constraintDescriptors = beanDescriptor.findConstraints()
        .declaredOn( ElementType.PARAMETER )
        .getConstraintDescriptors();
    assertEquals( constraintDescriptors.size(), 0 );
  }
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.