diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-01 00:18:55 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-01 00:18:55 +0200 |
commit | 5e7c489921f3141e62f229646d7f16c7b691be3d (patch) | |
tree | d1d4c269f92a0ef4da0447af1bbd6455f0aae7a8 /src/jrummikub | |
parent | b8fa08c9bb502b08e643c84c656f31cf0ad23f4d (diff) | |
download | JRummikub-5e7c489921f3141e62f229646d7f16c7b691be3d.tar JRummikub-5e7c489921f3141e62f229646d7f16c7b691be3d.zip |
Add 2-argument events
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@43 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r-- | src/jrummikub/util/Event2.java | 23 | ||||
-rw-r--r-- | src/jrummikub/util/IEvent2.java | 6 | ||||
-rw-r--r-- | src/jrummikub/util/IListener2.java | 5 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/jrummikub/util/Event2.java b/src/jrummikub/util/Event2.java new file mode 100644 index 0000000..19d2d58 --- /dev/null +++ b/src/jrummikub/util/Event2.java @@ -0,0 +1,23 @@ +package jrummikub.util; + +import java.util.HashSet; + +public class Event2<T1, T2> implements IEvent2<T1, T2> { +private HashSet<IListener2<T1, T2>> listeners = new HashSet<IListener2<T1, T2>>(); + + @Override + public void add(IListener2<T1, T2> listener) { + listeners.add(listener); + } + + @Override + public void remove(IListener2<T1, T2> listener) { + listeners.remove(listener); + } + + public void fire(T1 value1, T2 value2) { + for (IListener2<T1, T2> listener : listeners) { + listener.fire(value1, value2); + } + } +} diff --git a/src/jrummikub/util/IEvent2.java b/src/jrummikub/util/IEvent2.java new file mode 100644 index 0000000..f677a2d --- /dev/null +++ b/src/jrummikub/util/IEvent2.java @@ -0,0 +1,6 @@ +package jrummikub.util; + +public interface IEvent2<T1, T2> { + public void add(IListener2<T1, T2> listener); + public void remove(IListener2<T1, T2> listener); +} diff --git a/src/jrummikub/util/IListener2.java b/src/jrummikub/util/IListener2.java new file mode 100644 index 0000000..b1832c1 --- /dev/null +++ b/src/jrummikub/util/IListener2.java @@ -0,0 +1,5 @@ +package jrummikub.util; + +public interface IListener2<T1, T2> { + public void fire(T1 value1, T2 value2); +} |