@SuppressWarnings("unchecked")
    static <T extends JUnitWatcher> Optional<T> getAttachedWatcher(Class<T> watcherType) {
        if (MethodWatcher.class.isAssignableFrom(watcherType)) {
            synchronized(methodWatcherLoader) {
                for (MethodWatcher watcher : methodWatcherLoader) {
                    if (watcher.getClass() == watcherType) {
                        return Optional.of((T) watcher);
                    }
                }
            }
        }
        return Optional.absent();
    }
@ SuppressWarnings ( "unchecked" ) static < T extends JUnitWatcher > Optional < T > getAttachedWatcher ( Class < T > watcherType ) { if ( MethodWatcher . class . isAssignableFrom ( watcherType ) ) { synchronized ( methodWatcherLoader ) { for ( MethodWatcher watcher : methodWatcherLoader ) { if ( watcher . getClass ( ) == watcherType ) { return Optional . of ( ( T ) watcher ) ; } } } } return Optional . absent ( ) ; }
Get reference to an instance of the specified watcher type.

@param <T> watcher type
@param watcherType watcher type
@return optional watcher instance