@Test public void testRelatedSubjects() { SequenceDependenciesEventPublisher publisher = new SequenceDependenciesEventPublisher(); DetachedSubject a = new DetachedSubject("A", publisher); DetachedSubject b = new DetachedSubject("B", publisher); DetachedSubject c = new DetachedSubject("C", publisher); DetachedSubject d = new DetachedSubject("D", publisher); DetachedSubject e = new DetachedSubject("E", publisher); b.addListener(e); a.addListener(b); c.addListener(e); a.addListener(c); d.addListener(e); a.addListener(d); a.increment(10); assertEquals(10, a.latestRevision); assertEquals(10, b.latestRevision); assertEquals(10, c.latestRevision); assertEquals(10, d.latestRevision); assertEquals(10, e.latestRevision); }
public synchronized <Subject,Listener,Event> void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat) { List<SubjectAndListener> unordered = updateListEventListeners(subject, listener, null, eventFormat); subjectAndListeners = orderSubjectsAndListeners(unordered); }
SequenceDependenciesEventPublisher implements ListEventPublisher, Serializable { public synchronized <Subject,Listener,Event> void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat) { List<SubjectAndListener> unordered = updateListEventListeners(subject, listener, null, eventFormat); subjectAndListeners = orderSubjectsAndListeners(unordered); } }
SequenceDependenciesEventPublisher implements ListEventPublisher, Serializable { public synchronized <Subject,Listener,Event> void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat) { List<SubjectAndListener> unordered = updateListEventListeners(subject, listener, null, eventFormat); subjectAndListeners = orderSubjectsAndListeners(unordered); }  }
SequenceDependenciesEventPublisher implements ListEventPublisher, Serializable { public synchronized <Subject,Listener,Event> void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat) { List<SubjectAndListener> unordered = updateListEventListeners(subject, listener, null, eventFormat); subjectAndListeners = orderSubjectsAndListeners(unordered); }  synchronized void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat); synchronized void removeListener(Object subject, Object listener); @Override void setRelatedListener(Object subject, Object relatedListener); @Override void clearRelatedListener(Object subject, Object relatedListener); @Override void addDependency(EventList dependency, ListEventListener listener); @Override void removeDependency(EventList dependency, ListEventListener listener); @Override void setRelatedSubject(Object listener, Object relatedSubject); @Override void clearRelatedSubject(Object listener); synchronized List<Listener> getListeners(Object subject); void fireEvent(Subject subject, Event event, EventFormat<Subject,Listener,Event> eventFormat); }
SequenceDependenciesEventPublisher implements ListEventPublisher, Serializable { public synchronized <Subject,Listener,Event> void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat) { List<SubjectAndListener> unordered = updateListEventListeners(subject, listener, null, eventFormat); subjectAndListeners = orderSubjectsAndListeners(unordered); }  synchronized void addListener(Subject subject, Listener listener, EventFormat<Subject,Listener,Event> eventFormat); synchronized void removeListener(Object subject, Object listener); @Override void setRelatedListener(Object subject, Object relatedListener); @Override void clearRelatedListener(Object subject, Object relatedListener); @Override void addDependency(EventList dependency, ListEventListener listener); @Override void removeDependency(EventList dependency, ListEventListener listener); @Override void setRelatedSubject(Object listener, Object relatedSubject); @Override void clearRelatedSubject(Object listener); synchronized List<Listener> getListeners(Object subject); void fireEvent(Subject subject, Event event, EventFormat<Subject,Listener,Event> eventFormat);  }