class LibraryFileUpdateNotifier {

    public void onBatchIndexEvent(@Observes final BatchIndexEvent event) {
        event.getIndexEvents()
                .stream()
                .flatMap(evt -> {
                    switch (evt.getKind()) {
                        case Deleted:
                            return Stream.of(((IndexEvent.DeletedEvent) evt).getDeleted().getKey());
                        case NewlyIndexed:
                            return Stream.of(((IndexEvent.NewlyIndexedEvent) evt).getKObject().getKey());
                        case Renamed:
                            return Stream.of(((IndexEvent.RenamedEvent) evt).getTarget().getKey());
                        default:
                            return Stream.empty();
                    }
                })
                .map(pathStr -> {
                    final Path path = getPath(pathStr);
                    final WorkspaceProject project = workspaceProjectService.resolveProject(convertPath(path));
                    final String repositoryId = project.getRepository().getIdentifier();

                    final String branchName = (path instanceof JGitPathImpl) ?
                            ((JGitPathImpl) path).getRefTree() : null;

                    return new RepositoryFileListUpdatedEvent(repositoryId,
                                                              branchName);
                })
                .distinct()
                .forEach(repositoryFileListUpdatedEvent::fire);
    }

    @Inject public  LibraryFileUpdateNotifier(final WorkspaceProjectService workspaceProjectService,
                                     final Event<RepositoryFileListUpdatedEvent> repositoryFileListUpdatedEvent);

}