Created
September 14, 2017 20:18
-
-
Save sw-samuraj/a4d15b3b37c2d0129e57aed1517a69da to your computer and use it in GitHub Desktop.
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
@Resource(name = "userCache") | |
private Map<User, Id> userCache; | |
private UserStats getUser(String userID) { | |
String login = userCache | |
.entrySet() | |
.stream() | |
.filter(u -> userID.equals(u.getValue().getId())) | |
.map(u -> u.getKey().getLogin()) | |
.collect(Collectors.joining()); | |
return new UserStats().userID(userID).login(login); | |
} |
I don't remember context, nor assignment anymore - it's almost 3 years. But the point is to switch keys and values, so use id
as a key and user
as a value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sw-samuraj Can you please provide a refactored code for this snippet? I would like to see correct solution.