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