code: public static <T extends Annotation> T getDirectAnnotation(Class<T> annotationClass, AnnotatedElement element)
      {
          // Handle interfaces directly declared in the passed component class
          for (Annotation annotation : element.getDeclaredAnnotations()) {
              if (annotation.annotationType() == annotationClass) {
                  return (T) annotation;
              }
          }
  
          return null;
      }
docs: Get the first found annotation with the provided class directly assigned to the provided {@link AnnotatedElement}
  .
  
  @param <T> the type of the annotation
  @param annotationClass the annotation class
  @param element the class on which annotation are assigned
  @return the found annotation or null if there is none