@Test public void destroy() { final ObserverManager mgr = new ObserverManager(); final Obs observer = new Obs(); observer.last = null; mgr.addObserver(observer); mgr.fireEvent("hello"); assertEquals("hello", observer.last); observer.last = null; mgr.destroy(); mgr.fireEvent("I miss you"); assertNull(observer.last); }
public void destroy() { for (final Observer o : new LinkedList<>(observers)) { removeObserver(o.observer); } }
ObserverManager { public void destroy() { for (final Observer o : new LinkedList<>(observers)) { removeObserver(o.observer); } } }
ObserverManager { public void destroy() { for (final Observer o : new LinkedList<>(observers)) { removeObserver(o.observer); } }  }
ObserverManager { public void destroy() { for (final Observer o : new LinkedList<>(observers)) { removeObserver(o.observer); } }  boolean addObserver(final Object observer); boolean removeObserver(final Object observer); E fireEvent(final E event); void destroy(); }
ObserverManager { public void destroy() { for (final Observer o : new LinkedList<>(observers)) { removeObserver(o.observer); } }  boolean addObserver(final Object observer); boolean removeObserver(final Object observer); E fireEvent(final E event); void destroy();  }