blob: 52f46e63e0dfd6c05de308bb039677803ef90ab9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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<ExampleSet> exampleSets() {
return exampleSetDirectories()
.map(exampleDirectory -> new ExampleSet(exampleDirectory.toPath()));
}
/// The directory of each example set.
private static Stream<File> 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);
}
}
|