code: public static <T extends Annotation> Optional<T> getAnnotation(Class<?> beanClass, Class<T> annotationClass) {
  		Class<?> currentClass = beanClass;
  		while (currentClass != null && currentClass != Object.class) {
  			if (currentClass.isAnnotationPresent(annotationClass)) {
  				return Optional.of(currentClass.getAnnotation(annotationClass));
  			}
  			currentClass = currentClass.getSuperclass();
  		}
  
  		return Optional.empty();
  	}
docs: Returns an instance of bean's annotation
  
  @param beanClass       class to be searched for
  @param annotationClass type of an annotation
  @param <T>             type of an annotation
  @return an instance of an annotation