Source:
public boolean setCategoryFields(Map<String, String> fieldMap) { if (fieldMap == null || fieldMap.isEmpty()) { return false; } Map<String, List<String>> categoryFieldsMap = new LinkedHashMap<>(); for (String field : fieldMap.keySet()) { String category = fieldMap.get(field); if (!categoryFieldsMap.containsKey(category)) { categoryFieldsMap.put(category, new ArrayList<String>()); } categoryFieldsMap.get(category).add(field); } for (Element element : annotation.getApplicationInformation()) { String name = element.getLocalName(); if (APPINFO.equals(name.toLowerCase())) { name = element.getAttribute(SOURCE); if (name.equals(IAnnotationConst.KEY_CATEGORY)) { NodeList childNodes = element.getChildNodes(); List<Node> fieldNodes = new ArrayList<>(); String categoryName = null; for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); String localName = node.getLocalName(); if (localName != null) { Node subChild = node.getFirstChild(); if (subChild != null) { String nodeValue = subChild.getNodeValue(); if (nodeValue != null) { if (localName.equalsIgnoreCase(CATEGORY_NAME)) { categoryName = nodeValue; } else if (localName.equalsIgnoreCase(CATEGORY_FIELD) && nodeValue != null) { fieldNodes.add(node); } } } } } if (categoryName != null) { for (Node fieldNode : fieldNodes) { element.removeChild(fieldNode); } List<String> fields = categoryFieldsMap.get(categoryName); if (fields != null) { for (String field : fields) { Element fieldElement = element.getOwnerDocument().createElementNS(null, CATEGORY_FIELD); Node fieldValue = element.getOwnerDocument().createTextNode(field); fieldElement.appendChild(fieldValue); element.appendChild(fieldElement); hasChanged = true; } } } } } } if (hasChanged) { annotation.updateElement(); return true; } return false; }

Target:
public boolean setCategoryFields(Map<String, String> fieldMap) { if (fieldMap == null) { return false; } Map<String, List<String>> categoryFieldsMap = new LinkedHashMap<>(); for (String field : fieldMap.keySet()) { String category = fieldMap.get(field); if (!categoryFieldsMap.containsKey(category)) { categoryFieldsMap.put(category, new ArrayList<String>()); } categoryFieldsMap.get(category).add(field); } for (Element element : annotation.getApplicationInformation()) { String name = element.getLocalName(); if (APPINFO.equals(name.toLowerCase())) { name = element.getAttribute(SOURCE); if (name.equals(IAnnotationConst.KEY_CATEGORY)) { NodeList childNodes = element.getChildNodes(); List<Node> fieldNodes = new ArrayList<>(); String categoryName = null; for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); String localName = node.getLocalName(); if (localName != null) { Node subChild = node.getFirstChild(); if (subChild != null) { String nodeValue = subChild.getNodeValue(); if (nodeValue != null) { if (localName.equalsIgnoreCase(CATEGORY_NAME)) { categoryName = nodeValue; } else if (localName.equalsIgnoreCase(CATEGORY_FIELD) && nodeValue != null) { fieldNodes.add(node); } } } } } if (categoryName != null) { for (Node fieldNode : fieldNodes) { element.removeChild(fieldNode); } List<String> fields = categoryFieldsMap.get(categoryName); if (fields != null) { for (String field : fields) { Element fieldElement = element.getOwnerDocument().createElementNS(null, CATEGORY_FIELD); Node fieldValue = element.getOwnerDocument().createTextNode(field); fieldElement.appendChild(fieldValue); element.appendChild(fieldElement); hasChanged = true; } } } } } } if (hasChanged) { annotation.updateElement(); return true; } return false; }