code: public static <A extends Annotation> A getAnnotation(final Method m, final Class<A> type)
     {
        A result = m.getAnnotation(type);
        if (result == null)
        {
           for (Annotation a : m.getAnnotations())
           {
              result = getAnnotation(a, type);
  
              if (result != null)
              {
                 break;
              }
           }
        }
        if (result == null)
        {
           result = getAnnotation(m.getDeclaringClass(), type);
        }
        return result;
     }
docs: Inspect method <b>m</b> for a specific <b>type</b> of annotation. This also discovers annotations defined through
  a @ {@link Stereotype}.
  
  @param m The method to inspect.
  @param type The targeted annotation class
  @return The annotation instance found on this method or enclosing class, or null if no matching annotation was
  found.