class IndexDirectoryManager {

    public synchronized List<File> getDirectories(final Long startTime, final Long endTime) {
        final List<File> selected = new ArrayList<>();

        // An index cannot be expired if it is the latest index in the partition. As a result, we need to
        // separate the indexes by partition so that we can easily determine if this is the case.
        final Map<String, List<IndexLocation>> startTimeWithFileByStorageDirectory = flattenDirectoriesByTimestamp().stream()
            .collect(Collectors.groupingBy(indexLoc -> indexLoc.getPartitionName()));

        for (final List<IndexLocation> locationList : startTimeWithFileByStorageDirectory.values()) {
            selected.addAll(getDirectories(startTime, endTime, locationList));
        }

        return selected;
    }

    public  IndexDirectoryManager(final RepositoryConfiguration repoConfig);

}