Ejemplo n.º 1
0
  public synchronized EventResponse handle(Event event) {
    if (event.isOn()) {
      addEvent(event);
      alarm.start();
    } else {
      removeEvent(event);
      if (eventsWhichSetOffTheAlarm.size() == 0) {
        alarm.stop();
      }
    }

    return new EventResponse(alarm.isOn(), eventsWhichSetOffTheAlarm.values());
  }
Ejemplo n.º 2
0
 private void addEvent(Event event) {
   eventsWhichSetOffTheAlarm.put(event.getId(), event);
 }
Ejemplo n.º 3
0
 private void removeEvent(Event event) {
   eventsWhichSetOffTheAlarm.remove(event.getId());
 }