Skip to content

Commit

Permalink
support for detection of 'inherited' '@NotNull' elements per #395
Browse files Browse the repository at this point in the history
  • Loading branch information
stoicflame committed May 26, 2016
1 parent 0bbc783 commit defdba0
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class BeanValidationUtils {
private BeanValidationUtils() {}

public static boolean isNotNull(Element el) {
return isNotNull(el, true);
}

private static boolean isNotNull(Element el, boolean recurse) {
List<? extends AnnotationMirror> annotations = el.getAnnotationMirrors();
for (AnnotationMirror annotation : annotations) {
DeclaredType annotationType = annotation.getAnnotationType();
Expand All @@ -22,6 +26,10 @@ public static boolean isNotNull(Element el) {
if (annotationElement instanceof TypeElement && "javax.validation.constraints.NotNull".equals(((TypeElement) annotationElement).getQualifiedName().toString())) {
return true;
}

if (recurse) {
return isNotNull(annotationElement, false);
}
}
}

Expand Down

0 comments on commit defdba0

Please sign in to comment.