diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-05 19:56:46 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-05 19:56:46 +0200 |
commit | 5917f88a029c16c907616a991327d2e16ed5020b (patch) | |
tree | 62be0e721eafd66b535f602c27e028d799c525fe /mock/jrummikub/util | |
parent | 5c94d4f9a0648fcd36db3292abf229fb0767698a (diff) | |
download | JRummikub-5917f88a029c16c907616a991327d2e16ed5020b.tar JRummikub-5917f88a029c16c907616a991327d2e16ed5020b.zip |
Fixed MockEvents
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@152 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'mock/jrummikub/util')
-rw-r--r-- | mock/jrummikub/util/MockEvent.java | 9 | ||||
-rw-r--r-- | mock/jrummikub/util/MockEvent1.java | 9 | ||||
-rw-r--r-- | mock/jrummikub/util/MockEvent2.java | 9 |
3 files changed, 24 insertions, 3 deletions
diff --git a/mock/jrummikub/util/MockEvent.java b/mock/jrummikub/util/MockEvent.java index 2f0efe5..65aec9d 100644 --- a/mock/jrummikub/util/MockEvent.java +++ b/mock/jrummikub/util/MockEvent.java @@ -6,8 +6,15 @@ public class MockEvent implements IEvent { public HashSet<IListener> listeners = new HashSet<IListener>(); @Override - public void add(IListener listener) { + public Connection add(final IListener listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent.this.remove(listener); + } + }; } @Override diff --git a/mock/jrummikub/util/MockEvent1.java b/mock/jrummikub/util/MockEvent1.java index 74cae0f..94b0257 100644 --- a/mock/jrummikub/util/MockEvent1.java +++ b/mock/jrummikub/util/MockEvent1.java @@ -6,8 +6,15 @@ public class MockEvent1<T> implements IEvent1<T> { public HashSet<IListener1<T>> listeners = new HashSet<IListener1<T>>(); @Override - public void add(IListener1<T> listener) { + public Connection add(final IListener1<T> listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent1.this.remove(listener); + } + }; } @Override diff --git a/mock/jrummikub/util/MockEvent2.java b/mock/jrummikub/util/MockEvent2.java index 93e8228..5aa7b59 100644 --- a/mock/jrummikub/util/MockEvent2.java +++ b/mock/jrummikub/util/MockEvent2.java @@ -6,8 +6,15 @@ public class MockEvent2<T1, T2> implements IEvent2<T1, T2> { public HashSet<IListener2<T1, T2>> listeners = new HashSet<IListener2<T1, T2>>(); @Override - public void add(IListener2<T1, T2> listener) { + public Connection add(final IListener2<T1, T2> listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent2.this.remove(listener); + } + }; } @Override |