Element () { final Element actions = new Element("actions"); if (actionIdToAbbreviations.isEmpty()) { return actions; } Element result = null; for (Map.Entry<String, Set<String>> entry : actionIdToAbbreviations.entrySet()) { String key = entry.getKey(); Set<String> abbreviations = entry.getValue(); Set<String> pluginAbbreviations = pluginsActionIdToAbbreviations.get(key); if (Objects.equals(abbreviations, pluginAbbreviations)) { continue; } if (abbreviations != null) { if (result == null) { result = new Element("abbreviations"); actions.addContent(result); } final Element action = new Element("action"); action.setAttribute("id", key); result.addContent(action); for (String abbr : abbreviations) { Element abbreviation = new Element("abbreviation"); abbreviation.setAttribute("name", abbr); action.addContent(abbreviation); } } } return actions; }