package org.swellrt.server.box.events;

import org.waveprotocol.wave.model.util.Pair;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class EventQueueImpl implements EventQueue {

  private List<EventQueueListener> listeners = new ArrayList<EventQueueListener>();

  /**
   * Pair<App,DataType> = Set<Expression>
   */
  private Map<EventRuleClass, Set<String>> expressions =
 new HashMap<EventRuleClass, Set<String>>();

  @Override
  public void add(Event event) {
    for (EventQueueListener l : listeners)
      l.onEvent(event);
  }

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

  @Override
  public boolean hasEvents(String app, String dataType) {
    return expressions.containsKey(Pair.of(app, dataType));
  }

  @Override
  public Set<String> getExpressionPaths(String app, String dataType) {
    return expressions.get(Pair.of(app, dataType));
  }

  @Override
  public void registerConfigurator(EventQueueConfigurator configurator) {

    for (EventRuleClass appAndType : configurator.getEventRuleClasses()) {

      Set<String> paths = expressions.get(appAndType);
      if (paths == null) paths = new HashSet<String>();

      paths.addAll(configurator.getExpressionPaths(appAndType));
      expressions.put(appAndType, paths);
    }

  }

}

@@ -37,55 +37,8 @@
 s;%0A%0A
-import org.waveprotocol.wave.model.util.Pair;%0A%0A
 impo
@@ -57,24 +57,24 @@
 .ArrayList;%0A
+
 import java.
@@ -323,62 +323,8 @@
 );%0A%0A
-  /**%0A   * Pair%3CApp,DataType%3E = Set%3CExpression%3E%0A   */%0A
   pr
@@ -752,23 +752,34 @@
 ainsKey(
-Pair.of
+new EventRuleClass
 (app, da
@@ -907,15 +907,26 @@
 get(
-Pair.of
+new EventRuleClass
 (app

fix event queue map indexes bug