package org.shedlang.compiler.backends; import org.shedlang.compiler.filesystem.ShedCompilerFiles; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.Arrays; import java.util.stream.Stream; public class ExampleSet { public static Stream exampleSets() { return exampleSetDirectories() .map(exampleDirectory -> new ExampleSet(exampleDirectory.toPath())); } /// The directory of each example set. private static Stream exampleSetDirectories() { var examplesRoot = ShedCompilerFiles.getRoot().resolve("examples"); return Arrays.stream(examplesRoot.toFile() .listFiles(file -> file.isDirectory())); } private final Path path; private ExampleSet(Path path) { this.path = path; } public String name() { return this.path.getFileName().toString(); } public ExamplesConfig readConfig() throws IOException { return ExamplesConfig.read(this.path); } }