@Test public void unregisterEventHandler( ) { EventManager eventManager = new EventManager( this ); TestHandler handler1 = new TestHandler( ); TestHandler handler2 = new TestHandler( ); TestHandler handler3 = new TestHandler( ); TestHandler handler4 = new TestHandler( ); eventManager.registerEventHandler( Event.ANY, handler1 ); eventManager.registerEventHandler( testType, handler2 ); eventManager.registerEventHandler( testTestType, handler3 ); eventManager.registerEventHandler( otherType, handler4 ); eventManager.unregisterEventHandler( Event.ANY, handler1 ); Event event1 = new Event( testType, this ); eventManager.fireEvent( event1 ); assertEquals( 0, handler1.eventList.size( ) ); assertEquals( 1, handler2.eventList.size( ) ); assertEquals( 0, handler3.eventList.size( ) ); assertEquals( 0, handler4.eventList.size( ) ); eventManager.unregisterEventHandler( otherType, handler2 ); Event event2 = new Event( testType, this ); eventManager.fireEvent( event2 ); assertEquals( 0, handler1.eventList.size( ) ); assertEquals( 2, handler2.eventList.size( ) ); assertEquals( 0, handler3.eventList.size( ) ); assertEquals( 0, handler4.eventList.size( ) ); }
@Override public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { if (handlerMap.containsKey(type)) { handlerMap.get(type).remove(eventHandler); } }
EventManager implements EventSource { @Override public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { if (handlerMap.containsKey(type)) { handlerMap.get(type).remove(eventHandler); } } }
EventManager implements EventSource { @Override public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { if (handlerMap.containsKey(type)) { handlerMap.get(type).remove(eventHandler); } } EventManager(Object source); }
EventManager implements EventSource { @Override public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { if (handlerMap.containsKey(type)) { handlerMap.get(type).remove(eventHandler); } } EventManager(Object source); @Override void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); @Override void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); void fireEvent(Event fireEvent); }
EventManager implements EventSource { @Override public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { if (handlerMap.containsKey(type)) { handlerMap.get(type).remove(eventHandler); } } EventManager(Object source); @Override void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); @Override void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); void fireEvent(Event fireEvent);  }