for (int i = 0; i < departmentListSize; i++) {
String line = bufferedReader.readLine();
String[] lineTokens = splitByPipelineAndTrim(line, 2);
String[] departmentTokens = splitBySpace(lineTokens[0], 4);
Department department = new Department();
department.setId(Long.parseLong(departmentTokens[0]));
department.setName(departmentTokens[1]);
int minimumAge = Integer.parseInt(departmentTokens[2]);
if (minimumAge != 0) {
department.setMinimumAge(Integer.valueOf(minimumAge));
}
int maximumAge = Integer.parseInt(departmentTokens[3]);
if (maximumAge != 0) {
department.setMaximumAge(Integer.valueOf(maximumAge));
}
departmentList.add(department);
idToDepartmentMap.put(department.getId(), department);
String[] departmentSpecialismTokens = splitBySpace(lineTokens[1]);
if (departmentSpecialismTokens.length % 2 != 0) {
throw new IllegalArgumentException("Read line (" + line
+ ") is expected to contain even number of tokens (" + departmentSpecialismTokens.length