summaryrefslogtreecommitdiffstats
path: root/mock/jrummikub/util/MockEvent1.java
diff options
context:
space:
mode:
Diffstat (limited to 'mock/jrummikub/util/MockEvent1.java')
-rw-r--r--mock/jrummikub/util/MockEvent1.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/mock/jrummikub/util/MockEvent1.java b/mock/jrummikub/util/MockEvent1.java
new file mode 100644
index 0000000..74cae0f
--- /dev/null
+++ b/mock/jrummikub/util/MockEvent1.java
@@ -0,0 +1,23 @@
+package jrummikub.util;
+
+import java.util.HashSet;
+
+public class MockEvent1<T> implements IEvent1<T> {
+ public HashSet<IListener1<T>> listeners = new HashSet<IListener1<T>>();
+
+ @Override
+ public void add(IListener1<T> listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void remove(IListener1<T> listener) {
+ listeners.remove(listener);
+ }
+
+ public void emit(T value) {
+ for (IListener1<T> listener : listeners) {
+ listener.handle(value);
+ }
+ }
+}