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();
	}
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 ( ) ; }
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