// configElem should only contain other ConfigurationElemnents, so
// this case is non-conflicting
retVal.addChild(child);
}
else {
final ConfigurationElement oldChild = ConfigurationElement.class.cast(child);
if (!configElem.hasChildByName(oldChild.getName(), true))
retVal.addChild(oldChild);
}
}
// Add or merge from new config element
for (final PluginElement child : configElem.getChildren()) {
if (!(child instanceof ConfigurationElement)) {
throw new IllegalArgumentException("Cannot merge PluginElement of type " + child.getClass().getName());
}
else {
final ConfigurationElement newChild = ConfigurationElement.class.cast(child);
if (prev.hasChildByName(newChild.getName(), true)) {
retVal.addChild(merge(prev.getChildByName(newChild.getName(), true), newChild));
}
else {
retVal.addChild(newChild);
}
}