@VisibleForTesting FileChangeSet createFileChangeSet(){
  List<File> latest=Collections.emptyList();
  if (directory.isDirectory()) {
    latest=new ArrayList<>(asList(directory.listFiles(jsonFiles())));
  }
  Set<File> added=new HashSet<>();
  for (  File candidate : new ArrayList<>(latest)) {
    if (!snapshot.containsKey(candidate)) {
      added.add(candidate);
      latest.remove(candidate);
    }
  }
  Set<File> removed=new HashSet<>();
  for (  File candidate : new ArrayList<>(snapshot.keySet())) {
    if (!latest.contains(candidate)) {
      removed.add(candidate);
      snapshot.remove(candidate);
    }
  }
  Set<File> modified=new HashSet<>();
  for (  File candidate : latest) {
    long lastModified=snapshot.get(candidate);
    if (lastModified < candidate.lastModified()) {
      modified.add(candidate);
      snapshot.put(candidate,candidate.lastModified());
    }
  }
  for (  File file : added) {
    snapshot.put(file,file.lastModified());
  }
  return new FileChangeSet(directory,added,modified,removed);
}

@ VisibleForTesting FileChangeSet createFileChangeSet ( ) { List < File > latest = Collections . emptyList ( ) ; if ( directory . isDirectory ( ) ) { latest = new ArrayList < > ( asList ( directory . listFiles ( jsonFiles ( ) ) ) ) ; } Set < File > added = new HashSet < > ( ) ; for ( File candidate : new ArrayList < > ( latest ) ) { if ( ! snapshot . containsKey ( candidate ) ) { added . add ( candidate ) ; latest . remove ( candidate ) ; } } Set < File > removed = new HashSet < > ( ) ; for ( File candidate : new ArrayList < > ( snapshot . keySet ( ) ) ) { if ( ! latest . contains ( candidate ) ) { removed . add ( candidate ) ; snapshot . remove ( candidate ) ; } } Set < File > modified = new HashSet < > ( ) ; for ( File candidate : latest ) { long lastModified = snapshot . get ( candidate ) ; if ( lastModified < candidate . lastModified ( ) ) { modified . add ( candidate ) ; snapshot . put ( candidate , candidate . lastModified ( ) ) ; } } for ( File file : added ) { snapshot . put ( file , file . lastModified ( ) ) ; } return new FileChangeSet ( directory , added , modified , removed ) ; }
returns a snapshot of the changes compared to the previous scan .
