class SyncFileManager implements ISyncFileManager {

  @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
  @Override
  public void getValidFiles(String dataDir) throws IOException {
    allSGs = new HashMap<>();
    getCurrentLocalFiles(dataDir);
    getLastLocalFiles(
        new File(SyncSenderDescriptor.getInstance().getConfig().getLastFileInfoPath()));
    toBeSyncedFilesMap = new HashMap<>();
    deletedFilesMap = new HashMap<>();
    for (String sgName : allSGs.keySet()) {
      toBeSyncedFilesMap.putIfAbsent(sgName, new HashMap<>());
      deletedFilesMap.putIfAbsent(sgName, new HashMap<>());
      for (Entry<Long, Set<File>> entry : currentSealedLocalFilesMap
          .getOrDefault(sgName, Collections.emptyMap()).entrySet()) {
        Long timeRangeId = entry.getKey();
        toBeSyncedFilesMap.get(sgName).putIfAbsent(timeRangeId, new HashSet<>());
        allSGs.get(sgName).add(timeRangeId);
        for (File newFile : entry.getValue()) {
          if (!lastLocalFilesMap.getOrDefault(sgName, Collections.emptyMap())
              .getOrDefault(timeRangeId, Collections.emptySet()).contains(newFile)) {
            toBeSyncedFilesMap.get(sgName).get(timeRangeId).add(newFile);
          }
        }
      }

      for (Entry<Long, Set<File>> entry : lastLocalFilesMap
          .getOrDefault(sgName, Collections.emptyMap()).entrySet()) {
        Long timeRangeId = entry.getKey();
        deletedFilesMap.get(sgName).putIfAbsent(timeRangeId, new HashSet<>());
        allSGs.get(sgName).add(timeRangeId);
        for (File oldFile : entry.getValue()) {
          if (!currentSealedLocalFilesMap.getOrDefault(sgName, Collections.emptyMap())
              .getOrDefault(timeRangeId, Collections.emptySet()).contains(oldFile)) {
            deletedFilesMap.get(sgName).get(timeRangeId).add(oldFile);
          }
        }
      }
    }
  }

  private  SyncFileManager();

}