diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/util/Event.java | 10 | ||||
-rw-r--r-- | src/jrummikub/util/Event1.java | 10 | ||||
-rw-r--r-- | src/jrummikub/util/Event2.java | 10 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/jrummikub/util/Event.java b/src/jrummikub/util/Event.java index f76b861..491e10f 100644 --- a/src/jrummikub/util/Event.java +++ b/src/jrummikub/util/Event.java @@ -7,9 +7,15 @@ public class Event implements IEvent { private HashSet<IListener> listeners = new HashSet<IListener>(); @Override - public Connection add(IListener listener) { + public Connection add(final IListener listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event.this.remove(listener); + } + }; } @Override diff --git a/src/jrummikub/util/Event1.java b/src/jrummikub/util/Event1.java index ff6c037..d721a7e 100644 --- a/src/jrummikub/util/Event1.java +++ b/src/jrummikub/util/Event1.java @@ -12,9 +12,15 @@ public class Event1<T> implements IEvent1<T> { private HashSet<IListener1<T>> listeners = new HashSet<IListener1<T>>(); @Override - public Connection add(IListener1<T> listener) { + public Connection add(final IListener1<T> listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event1.this.remove(listener); + } + }; } @Override diff --git a/src/jrummikub/util/Event2.java b/src/jrummikub/util/Event2.java index 4b6575f..7087975 100644 --- a/src/jrummikub/util/Event2.java +++ b/src/jrummikub/util/Event2.java @@ -14,9 +14,15 @@ public class Event2<T1, T2> implements IEvent2<T1, T2> { private HashSet<IListener2<T1, T2>> listeners = new HashSet<IListener2<T1, T2>>(); @Override - public Connection add(IListener2<T1, T2> listener) { + public Connection add(final IListener2<T1, T2> listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event2.this.remove(listener); + } + }; } @Override |