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

import java.util.HashSet;

public class Event1<T> implements IEvent1<T> {
  private 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 fire(T value) {
    for (IListener1<T> listener : listeners) {
      listener.fire(value);
    }
  }
}