Fetches annotation for a given test class. If annotation is defined on method
level it's returned as a result. Otherwise class level annotation is returned if present.

@return T annotation or null if not found.
14845
public T fetchUsingFirst(Method testMethod) {
        T usedAnnotation = getAnnotationOnClassLevel();
        if (isDefinedOn(testMethod)) {
            usedAnnotation = fetchFrom(testMethod);
        }

        return usedAnnotation;
    }
390236
public static AnnotationNode getAnnotation(AnnotatedNode node, String name) {
        List<AnnotationNode> annotations = node.getAnnotations();
        for (AnnotationNode annot : annotations) {
            if (annot.getClassNode().getName().equals(name)) {
                return annot;
            }
        }
        return null;
    }
196211
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationClass) {
        A annotation = method.getAnnotation(annotationClass);
        if (annotation == null) {
            for (Annotation metaAnnotation : method.getAnnotations()) {
                annotation = metaAnnotation.annotationType().getAnnotation(annotationClass);
                if (annotation != null) {
                    return annotation;
                }
            }
            Method superclassMethod = getOverriddenMethod(method);
            if (superclassMethod != null) {
                annotation = getAnnotation(superclassMethod, annotationClass);
            }
        }
        return annotation;
    }
1048929
public static <T extends Annotation> Optional<T> getAnnotation(Class<?> beanClass, Class<T> annotationClass) {
		Class<?> currentClass = beanClass;
		while (currentClass != null && currentClass != Object.class) {
			if (currentClass.isAnnotationPresent(annotationClass)) {
				return Optional.of(currentClass.getAnnotation(annotationClass));
			}
			currentClass = currentClass.getSuperclass();
		}

		return Optional.empty();
	}
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;
  }
836133
@SuppressWarnings("rawtypes")
    public Method getAnnotatedMethod(Class clazz, Class<? extends Annotation> annotationClass) {
        Method m = null;

        Method[] methods = clazz.getDeclaredMethods();

        for (int i = 0; i < methods.length; i++) {
            Annotation[] a = methods[i].getAnnotations();
            if (a != null) {
                for (int j = 0; j < a.length; j++) {
                    if (a[j].annotationType() == annotationClass) {
                        if (m == null) {
                            m = methods[i];
                        } else {
                            Tr.warning(tc, "DUPLICATE_CALLBACK_METHOD_CWWKC2454W", new Object[] { methods[i].getName(), clazz.getName() });
                        }
                    }
                }
            }
        }
        return m;
    }
867240
public <A extends Annotation> A annotation(Class<A> annotationClass) {
        return field.getAnnotation(annotationClass);
    }
1061772
public Method findAnnotatedMethod(Class<?> clazz, Class<? extends Annotation> anno) {
    for (Method meth : clazz.getMethods()) {
      if (meth.isAnnotationPresent(anno)) {
        return meth;
      }
    }
    return null;
  }
627798
static <T extends Annotation> T getAnnotationFromGetterOrField(
            Method getter, Class<T> annotationClass) {
        // Check annotation on the getter method
        T onGetter = getter.getAnnotation(annotationClass);
        if (onGetter != null) {
            return onGetter;
        }

        // Check annotation on the corresponding field
        String fieldName = getFieldNameByGetter(getter, true);
        // Only consider the field declared in the same class where getter is defined.
        Field field = getClassFieldByName(getter.getDeclaringClass(), fieldName);
        T onField = null;
        if (field != null) {
            onField = field.getAnnotation(annotationClass);
        }
        return onField;
    }
33016
public static IAnnotationBinding getAnnotationBinding(
            IAnnotationBinding[] annotations, String annotationClassName) {
        if (annotations == null) {
            return null;
        }
        if (annotationClassName == null) {
            throw new NullPointerException();
        }

        for (IAnnotationBinding annotation : annotations) {
            String qName = annotation.getAnnotationType().getBinaryName();
            assert qName != null;
            // TODO if multiple annotations for annotationClassName exists
            if (qName.equals(annotationClassName)) {
                return annotation;
            }
        }
        return null;
    }
1220770
public AnnotationInfoList getAnnotationInfo() {
        if (!scanResult.scanSpec.enableAnnotationInfo) {
            throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()");
        }
        if (annotationInfo == null || annotationInfo.length == 0) {
            return AnnotationInfoList.EMPTY_LIST;
        } else {
            final AnnotationInfoList annotationInfoList = new AnnotationInfoList(annotationInfo.length);
            Collections.addAll(annotationInfoList, annotationInfo);
            return AnnotationInfoList.getIndirectAnnotations(annotationInfoList, /* annotatedClass = */ null);
        }
    }
203328
public static <T> T getAnnotation(final Class c, final Class<T> annotation) {
        final List<T> found = getAnnotations(c, annotation);
        if (found != null && !found.isEmpty()) {
            return found.get(0);
        } else {
            return null;
        }
    }
651850
public static <A extends Annotation> A getAnnotation(AnnotatedElement annotationEle, Class<A> annotationType) {
		return (null == annotationEle) ? null : toCombination(annotationEle).getAnnotation(annotationType);
	}
290133
<A extends Annotation> A findAnnotation(TypeElement element, Class<A> anno) {

    final A annotation = element.getAnnotation(anno);
    if (annotation != null) {
      return annotation;
    }
    final TypeMirror typeMirror = element.getSuperclass();
    if (typeMirror.getKind() == TypeKind.NONE) {
      return null;
    }
    final TypeElement element1 = (TypeElement)typeUtils.asElement(typeMirror);
    return findAnnotation(element1, anno);
  }
1372893
static <T extends Annotation> boolean getterOrFieldHasAnnotation(
            Method getter, Class<T> annotationClass) {
        return getAnnotationFromGetterOrField(getter, annotationClass) != null;
    }
561376
public <T extends DajlabModelInterface> T get(Class<T> clazz) {

		T ret = null;
		try {
			ret = (T) dajlab.get(clazz.getName());
		} catch (ClassCastException e) {
			e.printStackTrace();
		}
		return ret;
	}
286357
Class<? extends IJsonMarshaller> getMarshallerAnnotation(Annotation[] annotations) {
		JsonUnmarshaller ju = getJsonUnmarshallerAnnotation(annotations);
		return (ju != null) ? ju.value() : null;
	}