Package javax.validation.metadata

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


    Collection<ValidatorDescriptor> processBeanAttribute(FacesContext context, ValueDescriptor descriptor, String msg,
        Class<?>... groups) {
        PropertyDescriptor constraintsForProperty = getValidator(context).getConstraintsForClass(descriptor.getBeanType())
            .getConstraintsForProperty(descriptor.getName());
        if (null != constraintsForProperty) {
            ConstraintFinder propertyConstraints = constraintsForProperty.findConstraints();
            if (null != groups && groups.length > 0) {
                // Filter groups, if required
                propertyConstraints = propertyConstraints.unorderedAndMatchingGroups(groups);
            }
            Set<ConstraintDescriptor<?>> constraints = propertyConstraints // or the requested list of groups)
View Full Code Here


        "manufacturer"
    );

    //"manufacturer" constraints are declared on the getter, not the field
    assertTrue(
        manufacturerDescriptor.findConstraints()
            .declaredOn( ElementType.FIELD )
            .getConstraintDescriptors()
            .isEmpty()
    );
View Full Code Here

    );

    //@NotNull on Vehicle#getManufacturer() is part of another group
    assertEquals(
        1,
        manufacturerDescriptor.findConstraints()
            .unorderedAndMatchingGroups( Default.class )
            .getConstraintDescriptors()
            .size()
    );
View Full Code Here

    );

    //@Size on Car#getManufacturer()
    assertEquals(
        1,
        manufacturerDescriptor.findConstraints()
            .lookingAt( Scope.LOCAL_ELEMENT )
            .getConstraintDescriptors()
            .size()
    );
View Full Code Here

    );

    //@Size on Car#getManufacturer() and @NotNull on Vehicle#getManufacturer()
    assertEquals(
        2,
        manufacturerDescriptor.findConstraints()
            .lookingAt( Scope.HIERARCHY )
            .getConstraintDescriptors()
            .size()
    );
View Full Code Here

    );

    //Combining several filter options
    assertEquals(
        1,
        manufacturerDescriptor.findConstraints()
            .declaredOn( ElementType.METHOD )
            .lookingAt( Scope.HIERARCHY )
            .unorderedAndMatchingGroups( Vehicle.Basic.class )
            .getConstraintDescriptors()
            .size()
View Full Code Here

  }

  private boolean isGetterConstrained(Method method, BeanDescriptor beanDescriptor) {
    String propertyName = ReflectionHelper.getPropertyName( method );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );
    return propertyDescriptor != null && propertyDescriptor.findConstraints()
        .declaredOn( ElementType.METHOD )
        .hasConstraints();
  }

  private boolean veto(EnumSet<ExecutableType> classLevelExecutableTypes,
View Full Code Here

  }

  private boolean isGetterConstrained(Method method, BeanDescriptor beanDescriptor) {
    String propertyName = ReflectionHelper.getPropertyName( method );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );
    return propertyDescriptor != null && propertyDescriptor.findConstraints()
        .declaredOn( ElementType.METHOD )
        .hasConstraints();
  }

  private boolean veto(EnumSet<ExecutableType> classLevelExecutableTypes,
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.