boolean postChanges(Snapshot newState, Key key) {
      boolean changesPosted = false;

      if (key.subscribesTo(ENTRY_CREATE)) {
        Set<Name> created =
            Sets.difference(newState.modifiedTimes.keySet(), modifiedTimes.keySet());

        for (Name name : created) {
          key.post(new Event<>(ENTRY_CREATE, 1, pathService.createFileName(name)));
          changesPosted = true;
        }
      }

      if (key.subscribesTo(ENTRY_DELETE)) {
        Set<Name> deleted =
            Sets.difference(modifiedTimes.keySet(), newState.modifiedTimes.keySet());

        for (Name name : deleted) {
          key.post(new Event<>(ENTRY_DELETE, 1, pathService.createFileName(name)));
          changesPosted = true;
        }
      }

      if (key.subscribesTo(ENTRY_MODIFY)) {
        for (Map.Entry<Name, FileTime> entry : modifiedTimes.entrySet()) {
          Name name = entry.getKey();
          FileTime modifiedTime = entry.getValue();

          FileTime newModifiedTime = newState.modifiedTimes.get(name);
          if (newModifiedTime != null && !modifiedTime.equals(newModifiedTime)) {
            key.post(new Event<>(ENTRY_MODIFY, 1, pathService.createFileName(name)));
            changesPosted = true;
          }
        }
      }

      return changesPosted;
    }
Posts events to the given key based on the kinds of events it subscribes to and what events
have occurred between this state and the given new state.
jimfs/src/main/java/com/google/common/jimfs/PollingWatchService.java