/** * Recursively traverse the inheritance tree until a {@link Validated} annotation is reached. * * @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 traverseClassHierarchy(Class<?> original, Class<?> classToCheck) { boolean returnValue = false; Class<?> parentClass = classToCheck.getSuperclass(); if (parentClass != null) { returnValue = evaluateInheritance(original, parentClass); } for (Class<?> interfaces : classToCheck.getInterfaces()) { returnValue = evaluateInheritance(original, interfaces) || returnValue; } return returnValue; }