public static <T extends Annotation> T getAnnotationFromType(final Object instance, Class<T> annotation) {
        if (instance == null || annotation == null) {
            return null;
        }
        return instance.getClass().getAnnotation(annotation);
    }
public static <T extends Annotation> T getAnnotationFromType(final Object instance, Class<T> annotation) {
        if (instance == null || annotation == null) {
            return null;
        }
        return instance.getClass().getAnnotation(annotation);
    }
public static < T extends Annotation > T getAnnotationFromType ( final Object instance , Class < T > annotation ) { if ( instance == null || annotation == null ) { return null ; } return instance . getClass ( ) . getAnnotation ( annotation ) ; }
Gets an annotation of passed instance.

@param instance he instance to get the annotation from
@param <T>      the annotations class to get
@return the annotation if present, otherwise null
Gets an annotation of passed instance .