code: 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;
      }
docs: Returns an annotation by type from a method.
  
  @param method is the method to find
  @param annotationClass is the type of annotation
  @param <A> is the type of annotation
  @return annotation if it is found