Esempio n. 1
0
 public static IAnnotationBinding getAnnotation(IBinding binding, Class<?> annotationClass) {
   for (IAnnotationBinding annotation : binding.getAnnotations()) {
     if (typeEqualsClass(annotation.getAnnotationType(), annotationClass)) {
       return annotation;
     }
   }
   return null;
 }
Esempio n. 2
0
 /** Less strict version of the above where we don't care about the annotation's package. */
 public static boolean hasNamedAnnotation(IBinding binding, String annotationName) {
   for (IAnnotationBinding annotation : binding.getAnnotations()) {
     if (annotation.getName().equals(annotationName)) {
       return true;
     }
   }
   return false;
 }
Esempio n. 3
0
 /**
  * Return true if a binding has a named "Nonnull" annotation. Package names aren't checked because
  * different nonnull annotations are defined in several Java frameworks, with varying but similar
  * names.
  */
 public static boolean hasNonnullAnnotation(IBinding binding) {
   Pattern p = Pattern.compile("No[nt][Nn]ull");
   for (IAnnotationBinding annotation : binding.getAnnotations()) {
     if (p.matcher(annotation.getName()).matches()) {
       return true;
     }
   }
   return false;
 }