Add implementation for UserServiceImpl#1
Merged
vitalibutnar merged 1 commit intomasterfrom Oct 1, 2021
Merged
Conversation
vermurachi
reviewed
Sep 30, 2021
| public List<String> getFirstNamesReverseSorted(List<User> users) { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| return users.stream(). | ||
| map(User::getFirstName). |
There was a problem hiding this comment.
There is a reversed() method in Comparator that could be used
Owner
Author
There was a problem hiding this comment.
Thanks, it's a great idea
| @Override | ||
| public double getAverageAgeForUsers(final List<User> users) { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| return users.stream().mapToDouble(User::getAge).average().orElse(-1d); |
| @Override | ||
| public String convertTo(final List<User> users, final String delimiter, final Function<User, String> mapFun) { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| return users.stream().map(mapFun).reduce((res, str) -> res += delimiter + str).orElse(""); |
There was a problem hiding this comment.
could make it easier .collect(Collectors.joining(delimiter)) instead of reduce.
Owner
Author
There was a problem hiding this comment.
Yes, I've done it in extra homework but miss here
| @Override | ||
| public Optional<String> getMostFrequentLastName(final List<User> users) { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| Map<String, Long> map = users.stream().map(User::getLastName). |
There was a problem hiding this comment.
What if we have a list containing one user? should it return Optional.empty?
"optional of most frequent last name (if it encountered at least two times)"
Owner
Author
There was a problem hiding this comment.
There is a logical error in condition
0542e18 to
6672cd1
Compare
vermurachi
approved these changes
Sep 30, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add implementation for UserServiceImpl