package pl.warsjawa.java8.people;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;

import static java.util.stream.Collectors.toList;

public class PersonDao {

	public List<Person> loadPeopleDatabase() {
		try (BufferedReader bufferedReader = open("/people.csv")) {
			return bufferedReader.lines().
					filter(line -> !line.startsWith("#")).
					map(this::parseLine).
					filter(p -> !p.getName().isEmpty()).
					sorted(Comparator.comparing(Person::getName).thenComparing(Person::getDateOfBirth)).
					collect(toList());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	private BufferedReader open(String fileName) {
		return new BufferedReader(
				new InputStreamReader(
						getClass().getResourceAsStream(fileName),
						StandardCharsets.UTF_8));
	}

	private Person parseLine(String line) {
		final String[] columns = line.split(",");
		return new Person(
				columns[0],
				Sex.valueOf(columns[1]),
				Integer.parseInt(columns[3]),
				Integer.parseInt(columns[2]),
				LocalDate.of(
						Integer.parseInt(columns[6]),
						Integer.parseInt(columns[5]),
						Integer.parseInt(columns[4])
				)
		);
	}


}
@@ -211,24 +211,25 @@
 .util.Co
-mparator
+llections
 ;%0Aimport
@@ -250,59 +250,8 @@
 t;%0A%0A
-import static java.util.stream.Collectors.toList;%0A%0A
 publ
@@ -392,258 +392,69 @@
 urn 
-bufferedReader.lines().%0A%09%09%09%09%09filter(line -%3E !line.startsWith(%22#%22)).%0A%09%09%09%09%09map(this::parseLine).%0A%09%09%09%09%09filter(p -%3E !p.getName().isEmpty()).%0A%09%09%09%09%09sorted(Comparator.comparing(Person::getName).thenComparing(Person::getDateOfBirth)).%0A%09%09%09%09%09collect(toList());
+Collections.emptyList();%0A%09%09%09// return bufferedReader.lines().
 %0A%09%09%7D

Clean up