Skip to content

Conversation

mmgeorg
Copy link

@mmgeorg mmgeorg commented Apr 11, 2017

No description provided.

}
List<Person> actual = employees.stream()
.filter(e -> e.getJobHistory().stream()
.map(JobHistoryEntry::getEmployer).anyMatch(employer -> employer.equals("epam")))

Choose a reason for hiding this comment

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

Note that you could use .anyMatch("epam"::equals) instead.

List<Person> expected = new ArrayList<>();

for (Employee e : employees) {
if (e.getJobHistory().get(0).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 throws an exception on empty collection.

Map<String, List<Person>> employeesIndex = getEmployees().stream()
.map(e -> new PersonEmployerDuration(
e.getPerson(),
e.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.

final Map<Key, List<Value>> keyValuesMap1 = valueMap1.entrySet().stream()
.collect(toMap(e -> keyMap1.get(e.getKey()),
Map.Entry::getValue,
(values, values2) -> {

Choose a reason for hiding this comment

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

You can't get collision here. no need in this parameter.


final Map<Key, List<Value>> keyValuesMap2 = valuesMap2
.entrySet().stream()
.collect(toMap(e->keyMap2.get(e.getKey()),

Choose a reason for hiding this comment

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

Use groupingBy instead.

values.addAll(values2);
return values;
}));
Map.Entry::getValue));

Choose a reason for hiding this comment

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

Actually you may need conflict resolver here for null keys.

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