summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/util/Event.java
blob: 698e0edf689fb5a90c2c1744ed20cadef88784bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package jrummikub.util;

import java.util.HashSet;

/** Simple parameterless event generator */
public class Event implements IEvent {
	private HashSet<IListener> listeners = new HashSet<IListener>();

	@Override
	public void add(IListener listener) {
		listeners.add(listener);
	}

	@Override
	public void remove(IListener listener) {
		listeners.remove(listener);
	}

	/** Generate a single event */
	public void fire() {
		for (IListener listener : listeners) {
			listener.fire();
		}
	}
}