/** * Evaluate an individual node in the inheritance tree. * * @param original the original {@link Class} we are processing. * @param classToCheck the {@link Class} that we are checking which is in the inheritance tree of * {@code original} * @return true if any node in the inheritance tree is annotated with the {@link Validated} annotation. False * otherwise. */ private boolean evaluateInheritance(Class<?> original, Class<?> classToCheck) { Validated validated = classToCheck.getAnnotation(Validated.class); if (validated != null) { Set<Class<?>> set = supportedClassesCache.get(original); if (set == null) { set = new HashSet<>(); supportedClassesCache.put(original, set); } set.add(classToCheck); return true; } return traverseClassHierarchy(original, classToCheck); }
/** * Process any {@link Class} that is not annotated with the {@link Validated} annotation. * * @param clazz the {@link Class} to process. */ void processNonAnnotatedClasses(Class<?> clazz) { Validated validated = clazz.getAnnotation(Validated.class); if (validated != null) { throw new IllegalArgumentException( clazz.getCanonicalName() + " is annotated with " + Validated.class.getCanonicalName()); } if (!traverseClassHierarchy(clazz, clazz)) { unsupportedClassesCache.put(clazz, null); } addSupportedClass(clazz); getInstance().registerValidatorWithClass(this, clazz); }