Skip to content

Conversation

nikitos19
Copy link

@nikitos19 nikitos19 commented Apr 14, 2017

done by Gladun Nikita

@nikitos19 nikitos19 changed the title Streams completed by Gladun NIkita Streams completed Apr 14, 2017
List<Employee> employees = generateEmployeeList();

List<Person> personList = employees.stream()
.filter(e -> e.getJobHistory().get(0).getEmployer().equals("epam"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use get - it fails on empty collection.

throw new UnsupportedOperationException();
Map<String, List<Person>> employeesIndex = getEmployees().stream()
.map(employee -> new PersonEmployerPair(employee.getPerson(),
employee.getJobHistory().get(0).getEmployer(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid get.

// TODO
throw new UnsupportedOperationException();
Map<String, List<PersonPositionDuration>> map = employees.stream()
.flatMap(this::positionDuration)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify. You can ad additional method to aggregate durations for a single person like this flatMap(this::groupPersonDurations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants