Skip to content

Instantly share code, notes, and snippets.

@sw-samuraj
Created September 14, 2017 20:18
Show Gist options
  • Save sw-samuraj/a4d15b3b37c2d0129e57aed1517a69da to your computer and use it in GitHub Desktop.
Save sw-samuraj/a4d15b3b37c2d0129e57aed1517a69da to your computer and use it in GitHub Desktop.
@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);
}
@sw-samuraj
Copy link
Author

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