-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathLine.java
More file actions
64 lines (48 loc) · 1.23 KB
/
Line.java
File metadata and controls
64 lines (48 loc) · 1.23 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
64
package nextstep.subway.line;
import nextstep.subway.section.Section;
import nextstep.subway.section.Sections;
import javax.persistence.*;
import java.util.List;
import java.util.Map;
@Entity
public class Line {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(unique = true)
private String name;
@Column(unique = true)
private String color;
@Embedded
private final Sections sections = new Sections();
protected Line() { }
public Line(String name, String color) {
this.name = name;
this.color = color;
}
public Line(Long id, String name, String color) {
this.id = id;
this.name = name;
this.color = color;
}
public Long getId() {
return id;
}
public void addSection(Section section) {
section.toLine(this);
sections.add(section);
}
public String getName() {
return name;
}
public String getColor() {
return color;
}
public List<Map<String, Object>> getStations() {
return sections.getStationsResponse();
}
public void update(Line updateLine) {
this.name = updateLine.name;
this.color = updateLine.color;
}
}