-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstancesManager.java
More file actions
63 lines (52 loc) · 2.67 KB
/
Copy pathInstancesManager.java
File metadata and controls
63 lines (52 loc) · 2.67 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ssmdp.instance;
import java.util.List;
public final class InstancesManager {
private final List<InstanceFile> allInstances = List.of(
new InstanceFile("Type1/Type1.1.txt", "Type1 1", "Type1"),
new InstanceFile("Type1/Type1.2.txt", "Type1 2", "Type1"),
new InstanceFile("Type1/Type1.3.txt", "Type1 3", "Type1"),
new InstanceFile("Type1/Type1.4.txt", "Type1 4", "Type1"),
new InstanceFile("Type1/Type1.5.txt", "Type1 5", "Type1"),
new InstanceFile("Type1/Type1.6.txt", "Type1 6", "Type1"),
new InstanceFile("Type1/Type1.7.txt", "Type1 7", "Type1"),
new InstanceFile("Type1/Type1.8.txt", "Type1 8", "Type1"),
new InstanceFile("Type1/Type1.9.txt", "Type1 9", "Type1"),
new InstanceFile("Type1/Type1.10.txt", "Type1 10", "Type1"),
new InstanceFile("Type2/Type2.1.txt", "Type2 1", "Type2"),
new InstanceFile("Type2/Type2.2.txt", "Type2 2", "Type2"),
new InstanceFile("Type2/Type2.3.txt", "Type2 3", "Type2"),
new InstanceFile("Type2/Type2.4.txt", "Type2 4", "Type2"),
new InstanceFile("Type2/Type2.5.txt", "Type2 5", "Type2"),
new InstanceFile("Type2/Type2.6.txt", "Type2 6", "Type2"),
new InstanceFile("Type2/Type2.7.txt", "Type2 7", "Type2"),
new InstanceFile("Type2/Type2.8.txt", "Type2 8", "Type2"),
new InstanceFile("Type2/Type2.9.txt", "Type2 9", "Type2"),
new InstanceFile("Type2/Type2.10.txt", "Type2 10", "Type2"));
public List<InstanceFile> getInstances() {
return allInstances;
}
public List<InstanceFile> getInstancesByType(String type) {
return allInstances.stream()
.filter(instance -> instance.type().equals(type))
.toList();
}
public InstanceFile getInstance(int index) {
return allInstances.get(index);
}
public List<InstanceFile> getInstances(int fromIndex, int toIndex) {
return allInstances.subList(fromIndex, toIndex);
}
public InstanceFile getInstanceByType(String type, int index) {
return getInstancesByType(type).get(index);
}
public List<InstanceFile> getInstances(String type, int fromIndex, int toIndex) {
return getInstancesByType(type).subList(fromIndex, toIndex);
}
public InstanceFile getInstanceByFileName(String fileName) {
return allInstances.stream()
.filter(instance -> instance.fileName().equals(fileName))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"No instance with file name: " + fileName));
}
}