-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathLine.java
More file actions
35 lines (28 loc) · 771 Bytes
/
Copy pathLine.java
File metadata and controls
35 lines (28 loc) · 771 Bytes
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
package subway.domain;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public class Line {
private String name;
private final Set<UnitPath> paths = new HashSet<>();
public Line(String name) {
this.name = name;
}
public String getName() {
return name;
}
// 추가 기능 구현
public void addPath(UnitPath path){
paths.add(path);
}
public Optional<UnitPath> getPathOf(Station start, Station end) {
return paths.stream()
.filter(path -> path.isPathOf(start, end))
.findFirst();
}
public Set<UnitPath> getPaths() {
return Collections.unmodifiableSet(paths);
}
}