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());
  }
 private void addEvent(Event event) {
   eventsWhichSetOffTheAlarm.put(event.getId(), event);
 }
 private void removeEvent(Event event) {
   eventsWhichSetOffTheAlarm.remove(event.getId());
 }