code: public static boolean hasNamedAnnotation(AnnotatedConstruct ac, Pattern pattern) {
      for (AnnotationMirror annotation : ac.getAnnotationMirrors()) {
        if (pattern.matcher(getName(annotation.getAnnotationType().asElement())).matches()) {
          return true;
        }
      }
      return false;
    }
docs: Similar to the above but matches against a pattern.