### Question:
EventHandlers { public void dispatch(JibEvent jibEvent) { if (handlers.isEmpty()) { return; } handlers.get(JibEvent.class).forEach(handler -> handler.handle(jibEvent)); handlers.get(jibEvent.getClass()).forEach(handler -> handler.handle(jibEvent)); } private  EventHandlers(Multimap<Class<? extends JibEvent>, Handler<? extends JibEvent>> handlers); static Builder builder(); void dispatch(JibEvent jibEvent); static final EventHandlers NONE; }### Answer:
@Test public void testDispatch() { List<String> emissions = new ArrayList<>(); EventHandlers eventHandlers = EventHandlers.builder() .add(TestJibEvent2.class, testJibEvent2 -> emissions.add("handled 2 first")) .add(TestJibEvent2.class, testJibEvent2 -> emissions.add("handled 2 second")) .add(TestJibEvent3.class, testJibEvent3 -> emissions.add("handled 3")) .add(JibEvent.class, jibEvent -> emissions.add("handled generic")) .build(); TestJibEvent2 testJibEvent2 = new TestJibEvent2(); TestJibEvent3 testJibEvent3 = new TestJibEvent3(); eventHandlers.dispatch(testJibEvent2); eventHandlers.dispatch(testJibEvent3); Assert.assertEquals( Arrays.asList( "handled generic", "handled 2 first", "handled 2 second", "handled generic", "handled 3"), emissions); }