private static boolean hasAnnotation(ModifiersTree modifiers, String annotationName) {
   for (AnnotationTree annotation : modifiers.annotations()) {
     if (annotation.symbolType().is(annotationName)) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 2
0
 private static boolean hasOverrideAnnotation(MethodTree method) {
   for (AnnotationTree annotationTree : method.modifiers().annotations()) {
     Tree annotationType = annotationTree.annotationType();
     if (annotationType.is(Tree.Kind.IDENTIFIER)
         && "Override".equals(((IdentifierTree) annotationType).name())) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 3
0
 private static boolean isAnnotated(ClassTree tree) {
   for (AnnotationTree annotationTree : tree.modifiers().annotations()) {
     Tree annotationType = annotationTree.annotationType();
     if (annotationType.is(Tree.Kind.IDENTIFIER)
         && "FunctionalInterface".equals(((IdentifierTree) annotationType).name())) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 4
0
 public boolean isAnnotatedOverride() {
   for (AnnotationTree annotationTree : modifiers.annotations()) {
     if (annotationTree.annotationType().is(Tree.Kind.IDENTIFIER)) {
       IdentifierTree identifier = (IdentifierTree) annotationTree.annotationType();
       if (Override.class.getSimpleName().equals(identifier.name())) {
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public void visitAnnotation(AnnotationTree annotationTree) {
   scan(annotationTree.annotationType());
   // skip arguments of annotation as it should be compile time constant so it is not relevant
   // here.
 }
Exemplo n.º 6
0
 private static List<String> getSuppressWarningArgs(AnnotationTree annotationTree) {
   return getValueFromExpression(annotationTree.arguments().get(0));
 }
Exemplo n.º 7
0
 private static boolean isSuppressWarningsAnnotation(AnnotationTree annotationTree) {
   return annotationTree.annotationType().symbolType().is("java.lang.SuppressWarnings")
       && !annotationTree.arguments().isEmpty();
 }