Checks if the candidate is annotated by the specified annotation or meta-annotation.

@param annotationClass        the annotation to check for.
@param includeMetaAnnotations if true, meta-annotations are included in the search.
@return the predicate.
548733
public static <T extends Annotation> Predicate<T> annotationAnnotatedWith(Class<? extends Annotation>
            annotationClass, boolean includeMetaAnnotations) {
        return candidate -> elementAnnotatedWith(annotationClass, includeMetaAnnotations)
                .test(candidate.annotationType());
    }
625001
@Override
  public Description matchAnnotation(AnnotationTree tree, VisitorState state) {
    if (!ANNOTATION_MATCHER.matches(tree, state)) {
      return Description.NO_MATCH;
    }

    MethodTree methodTree = ASTHelpers.findEnclosingNode(state.getPath(), MethodTree.class);
    if (methodTree == null) {
      return Description.NO_MATCH;
    }

    MethodSymbol methodSym = ASTHelpers.getSymbol(methodTree);
    if (methodSym == null) {
      return Description.NO_MATCH;
    }

    if (!methodSym.getModifiers().contains(Modifier.ABSTRACT)) {
      return Description.NO_MATCH;
    }

    // Match, find the matched annotation to use for the error message.
    Symbol annotationSym = ASTHelpers.getSymbol(tree);
    if (annotationSym == null) {
      return Description.NO_MATCH;
    }

    return buildDescription(tree)
        .setMessage(
            String.format(
                "@%s cannot be applied to an abstract method", annotationSym.getSimpleName()))
        .build();
  }
210590
public static boolean areSameByClass(AnnotationMirror am, Class<? extends Annotation> anno) {
        return areSameByName(am, anno.getCanonicalName().intern());
    }
947644
public static boolean hasMethodWithAnnotation(Class<?> type,
                                                  Class<? extends Annotation> annotationType,
                                                  boolean checkMetaAnnotations) {
        try {
            do {
                Method[] methods = type.getDeclaredMethods();
                for (Method method : methods) {
                    if (hasAnnotation(method, annotationType, checkMetaAnnotations)) {
                        return true;
                    }
                }
                type = type.getSuperclass();
            } while (type != null);
        } catch (Throwable e) {
            // ignore a class loading issue
        }
        return false;
    }
202192
protected void initType(EnhancedAnnotation<T> annotatedAnnotation) {
        if (!Annotation.class.isAssignableFrom(getRawType())) {
            throw MetadataLogger.LOG.metaAnnotationOnWrongType(getMetaAnnotationTypes(), getRawType());
        }
    }
1172111
private boolean hasAnnotation(Class c, Class targetClass, AnnotationRepository annotationRepository)
   {
      Collection<Annotation> values = annotationRepository.getAnnotation(targetClass);
      if (values == null)
         return false;
      for (Annotation annotation : values)
      {
         if (annotation.getClassName() != null && annotation.getClassName().equals(c.getName()))
            return true;
      }
      return false;

   }
577635
private <T extends Annotation> T findAnnotation(Class<?> cls, Class<T> annotationClass, String name) {
    Class<?> curr = cls;
    T ann = null;
    while (ann == null && curr != null && !curr.equals(Object.class)) {
      ann = findAnnotationLocal(curr, annotationClass, name);
      curr = curr.getSuperclass();
    }
    return ann;
  }
641299
public static <T extends Tree> Matcher<T> hasAnnotation(
      final Class<? extends Annotation> inputClass) {
    return new Matcher<T>() {
      @Override
      public boolean matches(T tree, VisitorState state) {
        return ASTHelpers.hasAnnotation(ASTHelpers.getDeclaredSymbol(tree), inputClass, state);
      }
    };
  }
1074888
public static Class<? extends Annotation> checkIsBindingAnnotation(
      Class<? extends Annotation> annotation) {
    if (!isBindingAnnotation(annotation)) {
      throw new IllegalArgumentException(
          "Must be a binding annotation (BindingAnnotation or Qualifier)");
    }
    return annotation;
  }
481447
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
        boolean result = false;
        if (field != null) {
            result = field.isAnnotationPresent(annotationClass);
        }
        if (!result && setter != null) {
            result = setter.isAnnotationPresent(annotationClass);
        }
        if (!result && getter != null) {
            result = getter.isAnnotationPresent(annotationClass);
        }
        return result;
    }
921036
public <A extends Annotation> boolean hasAnnotationByGroup(final Class<A> annoClass, final Class<?>... groups) {
        
        return getAnnotationsByGroup(annoClass, groups).size() > 0;
        
    }
577766
public <A extends Annotation> List<A> getAnnotations(final Class<A> annoClass) {
        Objects.requireNonNull(annoClass, "annoClass should not be null.");
        
        return getAnnotationsByType(expandedAnnos, annoClass);
    }
667060
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) {
        Class mcc = mc.getClass();
        boolean valid = mcc == MetaClassImpl.class ||
                         mcc == AdaptingMetaClass.class ||
                         mcc == ClosureMetaClass.class ||
                         (includeEMC && mcc == ExpandoMetaClass.class);
        if (!valid) {
            if (LOG_ENABLED) LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.");
            return null;
        }
        if (LOG_ENABLED) LOG.info("meta class is a recognized MetaClassImpl");
        return (MetaClassImpl) mc;
    }
393159
public static Set<Annotation> getAllAnnotations(final Class<?> cls) {
		List<Class<?>> allTypes = ClassUtil.getAllSuperclasses(cls);
		allTypes.addAll(ClassUtil.getAllInterfaces(cls));
		allTypes.add(cls);

		Set<Annotation> anns = new HashSet<Annotation>();
		for (Class<?> type : allTypes) {
			anns.addAll(Arrays.asList(type.getDeclaredAnnotations()));
		}

		Set<Annotation> superAnnotations = new HashSet<Annotation>();
		for (Annotation ann : anns) {
			getSuperAnnotations(ann.annotationType(), superAnnotations);
		}

		anns.addAll(superAnnotations);

		return anns;
	}
1345237
protected static <A> A _getAnnotation(Class<A> annotationClass, Class endpointClass) {
        return annotationClass.cast(endpointClass.getAnnotation(annotationClass));
    }
537038
@Override
    public boolean isDeclaredAnnotationWithin(Collection<String> annotationNames) {
        if (declaredAnnotations != null) {
            for (AnnotationInfo annotation : declaredAnnotations) {
                if (annotationNames.contains(annotation.getAnnotationClassName())) {
                    return true;
                }
            }
        }

        return false;
    }
514408
public static Method findMethodWith(Class<?> searchClass, Class<? extends Annotation> annotationClass) {
		Method foundMethod = null;
		methodFinder: while (searchClass != null && searchClass != Object.class) {
			for (Method method : searchClass.getDeclaredMethods()) {
				if (method.isAnnotationPresent(annotationClass)) {
					foundMethod = method;
					break methodFinder;
				}
			}
			searchClass = searchClass.getSuperclass();
		}

		return foundMethod;
	}