Source:
<code>private void requestAuthors(Model model, String doi) throws IOException { Map<?,?> allAuthorsData = soaService.requestObject(String.format("articles/%s?authors", doi), Map.class); List<?> authors = (List<?>) allAuthorsData.get("authors"); model.addAttribute("authors", authors); List<String> correspondingAuthors = new ArrayList<>(); List<String> equalContributors = new ArrayList<>(); ListMultimap<String, String> authorAffiliationsMap = LinkedListMultimap.create(); for (Object o : authors) { Map<String, Object> author = (Map<String, Object>) o; String fullName = (String) author.get("fullName"); List<String> affiliations = (List<String>) author.get("affiliations"); for (String affiliation : affiliations) { authorAffiliationsMap.put(affiliation, fullName); } if (author.containsKey("corresponding")) { correspondingAuthors.add((String) author.get("corresponding")); } Object obj = author.get("equalContrib"); if (obj != null && (boolean) obj) { equalContributors.add(fullName); } List<String> currentAddresses = (List<String>) author.get("currentAddresses"); for (ListIterator<String> iterator = currentAddresses.listIterator(); iterator.hasNext(); ) { String currentAddress = iterator.next(); iterator.set(TextUtil.removeFootnoteMarker(currentAddress)); } } Map<String, String> authorListAffiliationMap = new HashMap<>(); <START> for (String affiliation : authorAffiliationsMap.asMap().keySet()) { <END> authorListAffiliationMap.put(affiliation, Joiner.on(", ") .join(authorAffiliationsMap.get(affiliation))); } model.addAttribute("authorListAffiliationMap", authorListAffiliationMap); model.addAttribute("authorContributions", allAuthorsData.get("authorContributions")); model.addAttribute("competingInterests", allAuthorsData.get("competingInterests")); model.addAttribute("correspondingAuthors", correspondingAuthors); model.addAttribute("equalContributors", equalContributors); }</code><technical_language>authorAffiliationsMap.asMap().entrySet() perform slightly better, prevent call authorAffiliationsMap.get below. (The difference big enough important, FYI.)</technical_language>

Target:
private void requestAuthors(Model model, String doi) throws IOException { Map<?,?> allAuthorsData = soaService.requestObject(String.format("articles/%s?authors", doi), Map.class); List<?> authors = (List<?>) allAuthorsData.get("authors"); model.addAttribute("authors", authors); List<String> correspondingAuthors = new ArrayList<>(); List<String> equalContributors = new ArrayList<>(); ListMultimap<String, String> authorAffiliationsMap = LinkedListMultimap.create(); for (Object o : authors) { Map<String, Object> author = (Map<String, Object>) o; String fullName = (String) author.get("fullName"); List<String> affiliations = (List<String>) author.get("affiliations"); for (String affiliation : affiliations) { authorAffiliationsMap.put(affiliation, fullName); } if (author.containsKey("corresponding")) { correspondingAuthors.add((String) author.get("corresponding")); } Object obj = author.get("equalContrib"); if (obj != null && (boolean) obj) { equalContributors.add(fullName); } List<String> currentAddresses = (List<String>) author.get("currentAddresses"); for (ListIterator<String> iterator = currentAddresses.listIterator(); iterator.hasNext(); ) { String currentAddress = iterator.next(); iterator.set(TextUtil.removeFootnoteMarker(currentAddress)); } } LinkedHashMap<String, String> authorListAffiliationMap = new LinkedHashMap<>(); for (Map.Entry<String, Collection<String>> affiliation : authorAffiliationsMap.asMap().entrySet()) { authorListAffiliationMap.put(affiliation.getKey(), Joiner.on(", ").join(affiliation.getValue())); } model.addAttribute("authorListAffiliationMap", authorListAffiliationMap); model.addAttribute("authorContributions", allAuthorsData.get("authorContributions")); model.addAttribute("competingInterests", allAuthorsData.get("competingInterests")); model.addAttribute("correspondingAuthors", correspondingAuthors); model.addAttribute("equalContributors", equalContributors); }