Importers { private static void importAll(Path parent, Importer importer, List<ReadOnlyDataSource> dataSources) throws IOException { if (Files.isDirectory(parent)) { try (Stream<Path> stream = Files.list(parent)) { stream.sorted().forEach(child -> { if (Files.isDirectory(child)) { try { importAll(child, importer, dataSources); } catch (IOException e) { throw new UncheckedIOException(e); } } else { addDataSource(parent, child, importer, dataSources); } }); } } else { if (parent.getParent() != null) { addDataSource(parent.getParent(), parent, importer, dataSources); } } } private  Importers(); static Collection<String> getFormats(ImportersLoader loader); static Collection<String> getFormats(); static Collection<Importer> list(ImportersLoader loader, ComputationManager computationManager, ImportConfig config); static Collection<Importer> list(ComputationManager computationManager, ImportConfig config); static Collection<Importer> list(); static Importer getImporter(ImportersLoader loader, String format, @Nullable ComputationManager computationManager, ImportConfig config); static Importer getImporter(String format, @Nullable ComputationManager computationManager, ImportConfig config); static Importer getImporter(String format, @Nullable ComputationManager computationManager); static Importer getImporter(String format); static Collection<String> getPostProcessorNames(ImportersLoader loader); static Collection<String> getPostProcessorNames(); static Importer addPostProcessors(ImportersLoader loader, Importer importer, ComputationManager computationManager, String... names); static Importer addPostProcessors(Importer importer, ComputationManager computationManager, String... names); static Importer addPostProcessors(Importer importer, String... names); static Importer setPostProcessors(ImportersLoader loader, Importer importer, ComputationManager computationManager, String... names); static Importer setPostProcessors(Importer importer, ComputationManager computationManager, String... names); static Importer setPostProcessors(Importer importer, String... names); static Importer removePostProcessors(Importer importer); static Network importData(ImportersLoader loader, String format, ReadOnlyDataSource dataSource, Properties parameters, ComputationManager computationManager, ImportConfig config); static Network importData(String format, ReadOnlyDataSource dataSource, Properties parameters, ComputationManager computationManager); static Network importData(String format, ReadOnlyDataSource dataSource, Properties parameters); static Network importData(String format, String directory, String baseName, Properties parameters); static void importAll(Path dir, Importer importer, boolean parallel, Properties parameters, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void importAll(Path dir, Importer importer, boolean parallel, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void importAll(Path dir, Importer importer, boolean parallel, Consumer<Network> consumer); @Deprecated static Object readParameter(String format, Properties parameters, Parameter configuredParameter); @Deprecated static Object readParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static DataSource createDataSource(Path file); static DataSource createDataSource(Path directory, String fileNameOrBaseName); static Importer findImporter(ReadOnlyDataSource dataSource, ImportersLoader loader, ComputationManager computationManager, ImportConfig config); static Importer findImporter(ReadOnlyDataSource dataSource, ComputationManager computationManager); static Network loadNetwork(Path file, ComputationManager computationManager, ImportConfig config, Properties parameters, ImportersLoader loader); static Network loadNetwork(Path file, ComputationManager computationManager, ImportConfig config, Properties parameters); static Network loadNetwork(Path file); static Network loadNetwork(String file); static Network loadNetwork(String filename, InputStream data, ComputationManager computationManager, ImportConfig config, Properties parameters, ImportersLoader loader); static Network loadNetwork(String filename, InputStream data, ComputationManager computationManager, ImportConfig config, Properties parameters); static Network loadNetwork(String filename, InputStream data, ComputationManager computationManager); static Network loadNetwork(String filename, InputStream data); static void loadNetworks(Path dir, boolean parallel, ImportersLoader loader, ComputationManager computationManager, ImportConfig config, Properties parameters, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void loadNetworks(Path dir, boolean parallel, ImportersLoader loader, ComputationManager computationManager, ImportConfig config, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void loadNetworks(Path dir, boolean parallel, ComputationManager computationManager, ImportConfig config, Properties parameters, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void loadNetworks(Path dir, boolean parallel, ComputationManager computationManager, ImportConfig config, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void loadNetworks(Path dir, boolean parallel, ComputationManager computationManager, ImportConfig config, Consumer<Network> consumer); static void loadNetworks(Path dir, boolean parallel, Consumer<Network> consumer); static void loadNetworks(Path dir, boolean parallel, Consumer<Network> consumer, Consumer<ReadOnlyDataSource> listener); static void loadNetworks(Path dir, Consumer<Network> consumer);  }
@Test public void importAll() throws InterruptedException, ExecutionException, IOException { List<Boolean> isLoadPresent = new ArrayList<>(); Importers.importAll(fileSystem.getPath(WORK_DIR), testImporter, false, n -> isLoadPresent.add(n.getLoad("LOAD") != null)); assertEquals(2, isLoadPresent.size()); isLoadPresent.forEach(Assert::assertTrue); }
@Test public void importAllParallel() throws InterruptedException, ExecutionException, IOException { List<Boolean> isLoadPresent = Collections.synchronizedList(new ArrayList<>()); Importers.importAll(fileSystem.getPath(WORK_DIR), testImporter, true, n -> isLoadPresent.add(n.getLoad("LOAD") != null)); assertEquals(2, isLoadPresent.size()); isLoadPresent.forEach(Assert::assertTrue); }