code: public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotationClass) {
          T t = method.getAnnotation(annotationClass);
          if (t == null) {
              t = getAnnotation(method.getDeclaringClass(), annotationClass);
          }
          return t;
      }
docs: Extract the annotation from the method or the declaring class.
  
  @param method
  @param annotationClass
  @param <T>
  @return the annotation or null