Element (@NotNull String kind, String path, Element classpathRoot, int index, Map<String, Element> oldEntries) { Element element = getOldElement(kind, path, oldEntries); if (element != null) { Element clonedElement = element.clone(); if (index == -1 || index >= classpathRoot.getContentSize()) { classpathRoot.addContent(clonedElement); } else { classpathRoot.addContent(index, clonedElement); } return clonedElement; } Element orderEntry = new Element(EclipseXml.CLASSPATHENTRY_TAG); orderEntry.setAttribute(EclipseXml.KIND_ATTR, kind); if (path != null) { orderEntry.setAttribute(EclipseXml.PATH_ATTR, path); } if (index == -1 || index >= classpathRoot.getContentSize()) { classpathRoot.addContent(orderEntry); } else { classpathRoot.addContent(index, orderEntry); } return orderEntry; }