List<CrewSegment> crewSegmentList = new ArrayList<CrewSegment>();
String line = bufferedReader.readLine();
long id = 0L;
while (!line.equals(";;;;;;")) {
String[] lineTokens = splitBySemicolonSeparatedValue(line, 2);
CrewSegment crewSegment = new CrewSegment();
crewSegment.setId(id);
id++;
RailNode home = nameToRailNodeMap.get(lineTokens[0]);
if (home == null) {
throw new IllegalArgumentException("Read line (" + line
+ ") has a non existing crew home (" + lineTokens[0] + ").");
}
crewSegment.setHome(home);
RailNode away = nameToRailNodeMap.get(lineTokens[1]);
if (away == null) {
throw new IllegalArgumentException("Read line (" + line
+ ") has a non existing crew away (" + lineTokens[1] + ").");
}
crewSegment.setAway(away);
crewSegmentList.add(crewSegment);
line = bufferedReader.readLine();
}
trainDesign.setCrewSegmentList(crewSegmentList);
}