class FileWatchEventCoalescor extends EventCoalescor<FileWatchEvent> {

	public void post(final FileWatchEvent event) {
		synchronized (queue) {
			final FileWatchEventKey key = FileWatchEventKey.fromEvent(event);

			Deque<EventReference> fileEvents;
			if ((fileEvents = queue.get(key)) == null) {
				// easy case, first event for a file, just queue it and schedule a post
				fileEvents = new ArrayDeque<>();
				queue.put(key, fileEvents);
				EventReference reference = EventReference.of(key, event);
				fileEvents.add(reference);
				schedulePost(reference);
				return;
			}

			// more complex case, we need to analyze the last saved event for this file
			EventReference last = fileEvents.getLast();
			if (!merge(last, event)) {
				// event has not been merged, so try to add it
				EventReference reference = EventReference.of(key, event);
				fileEvents.add(reference);
				schedulePost(reference);
			}
		}
	}

	  FileWatchEventCoalescor(EventBus eventBus, long coalescePeriod);

}