GenericEventListener implements EventListener<Event> { public final void onEvent(Event event) { Class<?> eventClass = event.getClass(); handleEventMethods.getOrDefault(eventClass, emptySet()).forEach(method -> { ThrowableConsumer.execute(method, m -> { m.invoke(this, event); }); }); } protected  GenericEventListener(); final void onEvent(Event event);  }
@Test public void testOnEvent() { String value = "Hello,World"; EchoEvent echoEvent = new EchoEvent(value); eventDispatcher.dispatch(echoEvent); assertEquals(echoEvent, listener.getEchoEvent()); assertEquals(value, listener.getEchoEvent().getSource()); }