in src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomUtils.java [56:98]
public static Xpp3Dom merge(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
if (recessive == null || isCombineSelfOverride(dominant)) {
return dominant;
}
if (isEmpty(dominant.getValue())) {
dominant.setValue(recessive.getValue());
}
for (String attr : recessive.getAttributeNames()) {
if (isEmpty(dominant.getAttribute(attr))) {
dominant.setAttribute(attr, recessive.getAttribute(attr));
}
}
if (recessive.getChildCount() > 0) {
boolean mergeChildren = isMergeChildren(dominant, childMergeOverride);
if (mergeChildren) {
Map<String, Iterator<Xpp3Dom>> commonChildren = getCommonChildren(dominant, recessive);
for (Xpp3Dom recessiveChild : recessive) {
Iterator<Xpp3Dom> it = commonChildren.get(recessiveChild.getName());
if (it == null) {
dominant.addChild(new Xpp3Dom(recessiveChild));
} else if (it.hasNext()) {
Xpp3Dom dominantChild = it.next();
merge(dominantChild, recessiveChild, childMergeOverride);
}
}
} else {
Xpp3Dom[] dominantChildren = dominant.getChildren();
dominant.childList.clear();
for (Xpp3Dom child : recessive) {
dominant.addChild(new Xpp3Dom(child));
}
for (Xpp3Dom aDominantChildren : dominantChildren) {
dominant.addChild(aDominantChildren);
}
}
}
return dominant;
}