Skip to content

Instantly share code, notes, and snippets.

@GaneshSamarthyam
Created September 8, 2019 09:27
Show Gist options
  • Save GaneshSamarthyam/7b74a6fa5340d3ba8e87afe5e50e8f06 to your computer and use it in GitHub Desktop.
Save GaneshSamarthyam/7b74a6fa5340d3ba8e87afe5e50e8f06 to your computer and use it in GitHub Desktop.
refactoring example
// 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) {
for (String value : values) {
List<String> existingValues = map.get(key);
if (existingValues == null) {
existingValues = new ArrayList<String>();
map.put(key, existingValues);
}
else {
existingValues.add(value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment