blob: 94b0257e60c178d27235c9fd2a8f500c03d1465f (
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
26
27
28
29
30
|
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 Connection add(final IListener1<T> listener) {
listeners.add(listener);
return new Connection() {
@Override
public void remove() {
MockEvent1.this.remove(listener);
}
};
}
@Override
public void remove(IListener1<T> listener) {
listeners.remove(listener);
}
public void emit(T value) {
for (IListener1<T> listener : listeners) {
listener.handle(value);
}
}
}
|