public <E extends GenericEvent>Event waitFor(@NonNull List<Class<? extends E>> eventClasses,long timeout,@NonNull TimeUnit unit) throws InterruptedException {
  while (true) {
    Event curEvent=eventQueue.poll(timeout,unit);
    if (curEvent == null)     return null;
    for (    Class<? extends GenericEvent> curEventClass : eventClasses)     if (curEventClass.isInstance(curEvent))     return curEvent;
  }
}

public < E extends GenericEvent > Event waitFor ( @ NonNull List < Class < ? extends E > > eventClasses , long timeout , @ NonNull TimeUnit unit ) throws InterruptedException { while ( true ) { Event curEvent = eventQueue . poll ( timeout , unit ) ; if ( curEvent == null ) return null ; for ( Class < ? extends GenericEvent > curEventClass : eventClasses ) if ( curEventClass . isInstance ( curEvent ) ) return curEvent ; } }
wait for events of the specified event class to appear in the queue . if the event was dispatched before this is called , it will return immediately . events that do not match the specified event class are discarded
