-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPillar.java
More file actions
49 lines (37 loc) · 1.24 KB
/
Pillar.java
File metadata and controls
49 lines (37 loc) · 1.24 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
package domain.ladder;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class Pillar {
private List<Bridge> bridges;
private Integer pillarNum;
private Pillar(List<Bridge> bridges, Integer pillarNum) {
this.bridges = bridges;
this.pillarNum = pillarNum;
}
public static Pillar of(List<Bridge> bridges, Integer pillarNum) {
return new Pillar(bridges, pillarNum);
}
public Integer getPillarNum() {
return pillarNum;
}
public List<Bridge> getBridges() {
return bridges;
}
public Optional<Bridge> getLevelBridges(Integer level) {
return bridges.stream()
.filter(bridge -> bridge.getLocation().equals(level))
.findFirst();
}
public List<Integer> getBridgesLocations() {
return bridges.stream()
.map(b -> b.getLocation())
.collect(Collectors.toList());
}
public List<Integer> getBridgesDirectionLocation(LinkedType linkedType) {
return bridges.stream()
.filter(b -> b.getLinkPillarDirection() == linkedType)
.map(bridge -> bridge.getLocation())
.collect(Collectors.toList());
}
}