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.java2
-rw-r--r--mock/jrummikub/util/MockEvent2.java3
-rw-r--r--mock/jrummikub/util/MockEvent3.java15
4 files changed, 16 insertions, 13 deletions
diff --git a/mock/jrummikub/util/MockEvent.java b/mock/jrummikub/util/MockEvent.java
index 3d4c56a..169e1e7 100644
--- a/mock/jrummikub/util/MockEvent.java
+++ b/mock/jrummikub/util/MockEvent.java
@@ -1,6 +1,7 @@
package jrummikub.util;
import java.util.HashSet;
+
/**
* Mock class for Events
*/
@@ -11,8 +12,8 @@ public class MockEvent implements IEvent {
@Override
public Connection add(final IListener listener) {
listeners.add(listener);
- return new Connection() {
-
+ return new Connection() {
+
@Override
public void remove() {
MockEvent.this.remove(listener);
@@ -24,10 +25,10 @@ public class MockEvent implements IEvent {
public void remove(IListener listener) {
listeners.remove(listener);
}
-
+
/** */
public void emit() {
- for (IListener listener : listeners) {
+ for (IListener listener : new HashSet<IListener>(listeners)) {
listener.handle();
}
}
diff --git a/mock/jrummikub/util/MockEvent1.java b/mock/jrummikub/util/MockEvent1.java
index 955215c..d8e2824 100644
--- a/mock/jrummikub/util/MockEvent1.java
+++ b/mock/jrummikub/util/MockEvent1.java
@@ -34,7 +34,7 @@ public class MockEvent1<T> implements IEvent1<T> {
* the event parameter
*/
public void emit(T value) {
- for (IListener1<T> listener : listeners) {
+ for (IListener1<T> listener : new HashSet<IListener1<T>>(listeners)) {
listener.handle(value);
}
}
diff --git a/mock/jrummikub/util/MockEvent2.java b/mock/jrummikub/util/MockEvent2.java
index bb4582f..5c25ca4 100644
--- a/mock/jrummikub/util/MockEvent2.java
+++ b/mock/jrummikub/util/MockEvent2.java
@@ -38,7 +38,8 @@ public class MockEvent2<T1, T2> implements IEvent2<T1, T2> {
* the second event parameter
*/
public void emit(T1 value1, T2 value2) {
- for (IListener2<T1, T2> listener : listeners) {
+ for (IListener2<T1, T2> listener : new HashSet<IListener2<T1, T2>>(
+ listeners)) {
listener.handle(value1, value2);
}
}
diff --git a/mock/jrummikub/util/MockEvent3.java b/mock/jrummikub/util/MockEvent3.java
index 62c3ed9..c154ca0 100644
--- a/mock/jrummikub/util/MockEvent3.java
+++ b/mock/jrummikub/util/MockEvent3.java
@@ -6,11 +6,11 @@ import java.util.HashSet;
* Mock class for Event2s
*
* @param <T1>
- * first event type
+ * first event type
* @param <T2>
- * second event type
+ * second event type
* @param <T3>
- * third event type
+ * third event type
*/
public class MockEvent3<T1, T2, T3> implements IEvent3<T1, T2, T3> {
/** */
@@ -35,14 +35,15 @@ public class MockEvent3<T1, T2, T3> implements IEvent3<T1, T2, T3> {
/**
* @param value1
- * the first event parameter
+ * the first event parameter
* @param value2
- * the second event parameter
+ * the second event parameter
* @param value3
- * the third event parameter
+ * the third event parameter
*/
public void emit(T1 value1, T2 value2, T3 value3) {
- for (IListener3<T1, T2, T3> listener : listeners) {
+ for (IListener3<T1, T2, T3> listener : new HashSet<IListener3<T1, T2, T3>>(
+ listeners)) {
listener.handle(value1, value2, value3);
}
}