Skip to content

Instantly share code, notes, and snippets.

@GaneshSamarthyam
Last active September 8, 2019 10:51
Show Gist options
  • Save GaneshSamarthyam/385b1660e64feceb84c950bdab40e0fa to your computer and use it in GitHub Desktop.
Save GaneshSamarthyam/385b1660e64feceb84c950bdab40e0fa to your computer and use it in GitHub Desktop.
Refactored solution for appendMapEntries
// Helper function to append values if not already present in the Map
protected void appendMapEntries(Map<String, List<String>> map, String key, List<String> values) {
values.forEach(value -> map.computeIfAbsent(key, k -> new ArrayList<>()).add(value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment