Skip to content

Commit 35df2ce

Browse files
committed
refactor: 중복 되는 메서드 제거
1. getLine 메서드를 LineRepository 클래스의 동일한 기능을 하는 메서드로 교체
1 parent 39b50c0 commit 35df2ce

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

src/main/java/subway/domain/selector/sectionitem/AddSectionItem.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,14 @@ public void execute() {
3838
}
3939

4040
private void addStation(String lineName, String stationName, int order) {
41-
Line line = getLine(lineName);
41+
Line line = LineRepository.getLineByName(lineName);
4242
List<Station> stations = line.stations();
4343
sectionValidator.validateSectionOrder(order, stations.size());
4444
Station station = new Station(stationName);
4545
sectionValidator.validateStationsDuplication(line, station);
4646
line.addStationByIndex(station, order - 1);
4747
}
4848

49-
private Line getLine(String lineName) {
50-
List<Line> lines = LineRepository.lines();
51-
52-
for (Line line : lines) {
53-
if (line.getName().equals(lineName)) {
54-
return line;
55-
}
56-
}
57-
return null;
58-
}
59-
6049
}
6150

6251

0 commit comments

Comments
 (0)