import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import com.google.common.collect.Maps;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.ModifyAction;
/**
* @author michal.rehak
- *
+ *
*/
public abstract class NodeUtils {
itemEl.setUserData(USER_KEY_NODE, item, null);
if (item instanceof SimpleNode<?>) {
Object value = ((SimpleNode<?>) item).getValue();
- itemEl.setTextContent(String.valueOf(value));
+ if(value != null) {
+ itemEl.setTextContent(String.valueOf(value));
+ }
}
if (item instanceof NodeModification) {
ModifyAction modificationAction = ((NodeModification) item).getModificationAction();
/**
* build NodeMap, where key = qName; value = node
- *
+ *
* @param value
* @return map of children, where key = qName and value is list of children
* groupped by qName
*/
public static Map<QName, List<Node<?>>> buildNodeMap(List<Node<?>> value) {
- Map<QName, List<Node<?>>> nodeMapTmp = new HashMap<>();
- if (value == null || value.isEmpty()) {
+ Map<QName, List<Node<?>>> nodeMapTmp = Maps.newLinkedHashMap();
+ if (value == null) {
throw new IllegalStateException("nodeList should not be null or empty");
}
for (Node<?> node : value) {
}
/**
- * @param path
- * @return
+ * @param qNamesPath
+ * @return path
*/
private static String schemaPathToPath(List<QName> qNamesPath) {
List<String> pathSeed = new ArrayList<>();
/**
* add given node to it's parent's list of children
- *
+ *
* @param newNode
*/
public static void fixParentRelation(Node<?> newNode) {
/**
* crawl all children of given node and assign it as their parent
- *
+ *
* @param parentNode
*/
public static void fixChildrenRelation(CompositeNode parentNode) {