summaryrefslogtreecommitdiffstats
path: root/mock/jrummikub/util
diff options
context:
space:
mode:
Diffstat (limited to 'mock/jrummikub/util')
-rw-r--r--mock/jrummikub/util/MockEvent.java9
-rw-r--r--mock/jrummikub/util/MockEvent1.java9
-rw-r--r--mock/jrummikub/util/MockEvent2.java9
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