private Class applyChecks()

in bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java [77:108]


    private Class<?> applyChecks(BeanType bean) {
        final Class<?> t = resolveClass.apply(bean.getClazz());

        final ClassType classType = bean.getClassType();
        if (classType != null) {
            constraints(new Meta.ForClass<>(t), classType.getConstraint());
        }
        final Set<String> fieldProperties = fieldProperties(t, bean.getField());
        final Set<String> getterProperties = getterProperties(t, bean.getGetter());
        final Set<Signature> methods = methods(t, bean.getMethod());
        @SuppressWarnings("unused")
        final Set<Signature> constructors = constructors(t, bean.getConstructor());

        final Set<String> propertyOverlap = new HashSet<>(fieldProperties);
        propertyOverlap.retainAll(getterProperties);

        if (!propertyOverlap.isEmpty()) {
            Exceptions.raise(ValidationException::new,
                "The following %s properties were specified via XML field and getter: %s", bean.getClazz(),
                propertyOverlap);
        }
        final Set<String> getterMethodOverlap = methods.stream().filter(s -> s.getParameterTypes().length == 0)
            .map(Signature::getName).filter(Methods::isGetter).map(Methods::propertyName)
            .filter(getterProperties::contains).collect(Collectors.toSet());

        if (!getterMethodOverlap.isEmpty()) {
            Exceptions.raise(ValidationException::new,
                "The following %s getters were specified via XML getter and method: %s", bean.getClazz(),
                getterMethodOverlap);
        }
        return t;
    }