diff options
Diffstat (limited to 'mock/jrummikub/util/MockEvent3.java')
-rw-r--r-- | mock/jrummikub/util/MockEvent3.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/mock/jrummikub/util/MockEvent3.java b/mock/jrummikub/util/MockEvent3.java new file mode 100644 index 0000000..fa1d105 --- /dev/null +++ b/mock/jrummikub/util/MockEvent3.java @@ -0,0 +1,45 @@ +package jrummikub.util; + +import java.util.HashSet; + +/** + * Mock class for Event2s + * + * @param <T1> + * first event type + * @param <T2> + * second event type + */ +public class MockEvent3<T1, T2, T3> implements IEvent3<T1, T2, T3> { + /** */ + public HashSet<IListener3<T1, T2, T3>> listeners = new HashSet<IListener3<T1, T2, T3>>(); + + @Override + public Connection add(final IListener3<T1, T2, T3> listener) { + listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent3.this.remove(listener); + } + }; + } + + @Override + public void remove(IListener3<T1, T2, T3> listener) { + listeners.remove(listener); + } + + /** + * @param value1 + * the first event parameter + * @param value2 + * the second event parameter + */ + public void emit(T1 value1, T2 value2, T3 value3) { + for (IListener3<T1, T2, T3> listener : listeners) { + listener.handle(value1, value2, value3); + } + } +} |