-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathLine.java
More file actions
41 lines (33 loc) · 1003 Bytes
/
Line.java
File metadata and controls
41 lines (33 loc) · 1003 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
36
37
38
39
40
41
package nextstep.ladder.domain;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class Line {
private final Connections connections;
public Line(Boolean...connections) {
this(Arrays.stream(connections)
.map(Connection::new)
.collect(Collectors.toUnmodifiableList()));
}
public Line(List<Connection> connections) {
this(new Connections(connections));
}
public Line(Connections connections) {
this.connections = connections;
}
public List<Connection> connections() {
return connections.connections();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Line)) return false;
Line line = (Line) o;
return Objects.equals(connections, line.connections);
}
@Override
public int hashCode() {
return Objects.hash(connections);
}
}