code: @SuppressWarnings("unchecked")
     public static <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> ann) {
        while (true) {
           // first check class
           T a = clazz.getAnnotation(ann);
           if (a != null) return a;
  
           // check interfaces
           if (!clazz.isInterface()) {
              Class<?>[] interfaces = clazz.getInterfaces();
              for (Class<?> inter : interfaces) {
                 a = getAnnotation(inter, ann);
                 if (a != null) return a;
              }
           }
  
           // check superclasses
           Class<?> superclass = clazz.getSuperclass();
           if (superclass == null) return null; // no where else to look
           clazz = superclass;
        }
     }
docs: Inspects the class passed in for the class level annotation specified.  If the annotation is not available, this
  method recursively inspects superclasses and interfaces until it finds the required annotation.
  <p/>
  Returns null if the annotation cannot be found.
  
  @param clazz class to inspect
  @param ann   annotation to search for.  Must be a class-level annotation.
  @return the annotation instance, or null