Skip to content

Streams completed #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Streams completed #57

wants to merge 1 commit into from

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