BUG-868: stop using getChildren() 93/7393/1
authorRobert Varga <rovarga@cisco.com>
Mon, 26 May 2014 09:36:07 +0000 (11:36 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 26 May 2014 09:36:07 +0000 (11:36 +0200)
This removes users of getChildren() in favor of getValue().

Change-Id: I1b871b46cd3af04dba1d286f386e43148308fbe1
Signed-off-by: Robert Varga <rovarga@cisco.com>
13 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/RuntimeGeneratedMappingServiceImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/LazyNodeToNodeMap.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeFactory.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeModificationBuilderImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/XmlTreeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/LazyNodeToNodeMapTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/MyNodeBuilder.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/NodeFactoryTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/NodeHelper.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/NodeUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/XmlTreeBuilderTest.java

index e6dc334e3ea566f48979d4a696b23a2ef403bb22..767259bc26631c93474c24e513fc91c0083cdc22 100644 (file)
@@ -261,7 +261,7 @@ public class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMap
             for (Map.Entry<QName, Object> predicate : predicates.getKeyValues().entrySet()) {
                 newNodes.add(new SimpleNodeTOImpl<Object>(predicate.getKey(), null, predicate.getValue()));
             }
-            newNodes.addAll(ret.getChildren());
+            newNodes.addAll(ret.getValue());
             return new CompositeNodeTOImpl(last.getNodeType(), null, newNodes);
         }
         return ret;
index 2d761980a6f2066eeceaff851754400c19476cbb..0282cae6021104c28daa774ae659239abf3f0163 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.data.api.SimpleNode;
  */
 public class LazyNodeToNodeMap {
 
-    private Map<Node<?>, Node<?>> node2node = new HashMap<>();
+    private final Map<Node<?>, Node<?>> node2node = new HashMap<>();
     private CompositeNode originalRoot;
     private MutableCompositeNode mutableRoot;
 
@@ -35,7 +35,7 @@ public class LazyNodeToNodeMap {
      * @param originalNode
      * @return mutable twin
      */
-    public Node<?> getMutableEquivalent(Node<?> originalNode) {
+    public Node<?> getMutableEquivalent(final Node<?> originalNode) {
         Node<?> mutableNode = node2node.get(originalNode);
         if (mutableNode == null) {
             addPathMembers(originalNode);
@@ -48,7 +48,7 @@ public class LazyNodeToNodeMap {
     /**
      * @param originalNode
      */
-    private void addPathMembers(Node<?> originalNode) {
+    private void addPathMembers(final Node<?> originalNode) {
         Stack<Node<?>> jobQueue = new Stack<>();
         jobQueue.push(originalNode);
         while (!jobQueue.isEmpty()) {
@@ -84,15 +84,15 @@ public class LazyNodeToNodeMap {
                 mutableEquivalent = nodeMutant;
 
                 // tidy up children
-                if (nodeMutant.getChildren() == null) {
+                if (nodeMutant.getValue() == null) {
                     nodeMutant.setValue(new ArrayList<Node<?>>());
                 }
-                for (Node<?> originalChildNode : ((CompositeNode) node2add).getChildren()) {
+                for (Node<?> originalChildNode : ((CompositeNode) node2add).getValue()) {
                     MutableNode<?> mutableChild = (MutableNode<?>) node2node.get(originalChildNode);
                     fixChildrenRef(nodeMutant, mutableChild);
                 }
 
-                if (nodeMutant.getChildren() != null && !nodeMutant.getChildren().isEmpty()) {
+                if (nodeMutant.getValue() != null && !nodeMutant.getValue().isEmpty()) {
                     nodeMutant.init();
                 }
 
@@ -122,11 +122,11 @@ public class LazyNodeToNodeMap {
      * @param nodeMutant
      * @param mutableChild
      */
-    private static void fixChildrenRef(MutableCompositeNode nodeMutant,
-            MutableNode<?> mutableChild) {
+    private static void fixChildrenRef(final MutableCompositeNode nodeMutant,
+            final MutableNode<?> mutableChild) {
         if (mutableChild != null) {
-            if (!nodeMutant.getChildren().contains(mutableChild)) {
-                nodeMutant.getChildren().add(mutableChild);
+            if (!nodeMutant.getValue().contains(mutableChild)) {
+                nodeMutant.getValue().add(mutableChild);
             }
             CompositeNode parentOfChild = mutableChild.getParent();
             if (parentOfChild == null) {
index c764cdb36c2e850390565a6e62f5419aac39739a..735ff27c44957cfd154fc49a30c421fcd5d8e7e2 100644 (file)
@@ -36,8 +36,8 @@ public abstract class NodeFactory {
      * @param value
      * @return simple node modification, based on given qname, value and parent
      */
-    public static <T> SimpleNode<T> createImmutableSimpleNode(QName qName,
-            CompositeNode parent, T value) {
+    public static <T> SimpleNode<T> createImmutableSimpleNode(final QName qName,
+            final CompositeNode parent, final T value) {
         return createImmutableSimpleNode(qName, parent, value, null);
     }
 
@@ -49,8 +49,8 @@ public abstract class NodeFactory {
      * @param original originating node, if available
      * @return simple node modification, based on given qname, value and parent
      */
-    public static <T> MutableSimpleNode<T> createMutableSimpleNode(QName qName,
-            CompositeNode parent, Object value, ModifyAction modifyAction, SimpleNode<T> original) {
+    public static <T> MutableSimpleNode<T> createMutableSimpleNode(final QName qName,
+            final CompositeNode parent, final Object value, final ModifyAction modifyAction, final SimpleNode<T> original) {
         @SuppressWarnings("unchecked")
         MutableSimpleNodeTOImpl<T> simpleNodeTOImpl =
                 new MutableSimpleNodeTOImpl<T>(qName, parent, (T) value, modifyAction);
@@ -64,8 +64,8 @@ public abstract class NodeFactory {
      * @param value
      * @return composite node modification, based on given qname, value (children), parent and modifyAction
      */
-    public static CompositeNode createImmutableCompositeNode(QName qName,
-            CompositeNode parent, List<Node<?>> value) {
+    public static CompositeNode createImmutableCompositeNode(final QName qName,
+            final CompositeNode parent, final List<Node<?>> value) {
         return createImmutableCompositeNode(qName, parent, value, null);
     }
 
@@ -77,8 +77,8 @@ public abstract class NodeFactory {
      * @param original originating node, if available
      * @return composite node modification, based on given qName, value (children), parent and modifyAction
      */
-    public static MutableCompositeNode createMutableCompositeNode(QName qName,
-            CompositeNode parent, List<Node<?>> valueArg, ModifyAction modifyAction, CompositeNode original) {
+    public static MutableCompositeNode createMutableCompositeNode(final QName qName,
+            final CompositeNode parent, final List<Node<?>> valueArg, final ModifyAction modifyAction, final CompositeNode original) {
         List<Node<?>> value = valueArg;
         if (value == null) {
             value = new ArrayList<>();
@@ -97,8 +97,8 @@ public abstract class NodeFactory {
      * @param modifyAction
      * @return simple node modification, based on given qname, value, parent and modifyAction
      */
-    public static <T> SimpleNode<T> createImmutableSimpleNode(QName qName,
-            CompositeNode parent, T value, ModifyAction modifyAction) {
+    public static <T> SimpleNode<T> createImmutableSimpleNode(final QName qName,
+            final CompositeNode parent, final T value, final ModifyAction modifyAction) {
         SimpleNodeTOImpl<T> simpleNodeModTOImpl =
                 new SimpleNodeTOImpl<T>(qName, parent, value, modifyAction);
         return simpleNodeModTOImpl;
@@ -111,8 +111,8 @@ public abstract class NodeFactory {
      * @param modifyAction
      * @return composite node modification, based on given qname, value (children), parent and modifyAction
      */
-    public static CompositeNode createImmutableCompositeNode(QName qName,
-            CompositeNode parent, List<Node<?>> value, ModifyAction modifyAction) {
+    public static CompositeNode createImmutableCompositeNode(final QName qName,
+            final CompositeNode parent, final List<Node<?>> value, final ModifyAction modifyAction) {
         CompositeNodeTOImpl compositeNodeModTOImpl =
                 new CompositeNodeTOImpl(qName, parent, value, modifyAction);
         return compositeNodeModTOImpl;
@@ -123,7 +123,7 @@ public abstract class NodeFactory {
      * @return copy of given node, parent and value are the same, but parent
      * has no reference to this copy
      */
-    public static <T> SimpleNode<T> copyNode(SimpleNode<T> node) {
+    public static <T> SimpleNode<T> copyNode(final SimpleNode<T> node) {
         SimpleNode<T> twinNode = createImmutableSimpleNode(
                     node.getNodeType(), node.getParent(), node.getValue());
         return twinNode;
@@ -134,7 +134,7 @@ public abstract class NodeFactory {
      * @return copy of given node, parent and value are the same, but parent
      * has no reference to this copy
      */
-    public static <T> MutableSimpleNode<T> copyNodeAsMutable(SimpleNode<T> node) {
+    public static <T> MutableSimpleNode<T> copyNodeAsMutable(final SimpleNode<T> node) {
         MutableSimpleNode<T> twinNode = createMutableSimpleNode(
                     node.getNodeType(), node.getParent(), node.getValue(),
                     node.getModificationAction(), null);
@@ -147,7 +147,7 @@ public abstract class NodeFactory {
      * @return copy of given node, parent and children are the same, but parent and children
      * have no reference to this copy
      */
-    public static CompositeNode copyNode(CompositeNode node, Node<?>... children) {
+    public static CompositeNode copyNode(final CompositeNode node, final Node<?>... children) {
         CompositeNode twinNode = createImmutableCompositeNode(
                 node.getNodeType(), node.getParent(), Arrays.asList(children), node.getModificationAction());
         return twinNode;
@@ -158,8 +158,8 @@ public abstract class NodeFactory {
      * @return copy of given node, parent and children are the same, but parent and children
      * have no reference to this copy
      */
-    public static CompositeNode copyNode(CompositeNode node) {
-       return copyNode(node, node.getChildren().toArray(new Node<?>[0]));
+    public static CompositeNode copyNode(final CompositeNode node) {
+       return copyNode(node, node.getValue().toArray(new Node<?>[0]));
     }
 
     /**
@@ -168,8 +168,8 @@ public abstract class NodeFactory {
      * will be stored
      * @return copy of given node and all subnodes recursively
      */
-    public static MutableCompositeNode copyDeepAsMutable(CompositeNode node,
-            Map<Node<?>, Node<?>> originalToCopyArg) {
+    public static MutableCompositeNode copyDeepAsMutable(final CompositeNode node,
+            final Map<Node<?>, Node<?>> originalToCopyArg) {
 
         Map<Node<?>, Node<?>> originalToCopy = originalToCopyArg;
         if (originalToCopy == null) {
@@ -188,7 +188,7 @@ public abstract class NodeFactory {
             MutableCompositeNode mutableNode = job.getValue();
             mutableNode.setValue(new ArrayList<Node<?>>());
 
-            for (Node<?> child : originalNode.getChildren()) {
+            for (Node<?> child : originalNode.getValue()) {
                 Node<?> mutableAscendant = null;
                 if (child instanceof CompositeNode) {
                     MutableCompositeNode newMutable =
@@ -207,7 +207,7 @@ public abstract class NodeFactory {
                             +child.getClass().getName());
                 }
 
-                mutableNode.getChildren().add(mutableAscendant);
+                mutableNode.getValue().add(mutableAscendant);
                 originalToCopy.put(child, mutableAscendant);
             }
             mutableNode.init();
@@ -222,8 +222,8 @@ public abstract class NodeFactory {
      * will be stored
      * @return copy of given node and all subnodes recursively
      */
-    public static CompositeNode copyDeepAsImmutable(CompositeNode node,
-            Map<Node<?>, Node<?>> originalToCopyArg) {
+    public static CompositeNode copyDeepAsImmutable(final CompositeNode node,
+            final Map<Node<?>, Node<?>> originalToCopyArg) {
         Stack<CompositeNode> jobQueue = new Stack<>();
         jobQueue.push(node);
 
@@ -235,15 +235,15 @@ public abstract class NodeFactory {
         while (!jobQueue.isEmpty()) {
             CompositeNode jobNode = jobQueue.peek();
             if (!originalToCopy.isEmpty()
-                    && originalToCopy.keySet().containsAll(jobNode.getChildren())) {
+                    && originalToCopy.keySet().containsAll(jobNode.getValue())) {
                 jobQueue.pop();
-                List<Node<?>> newChildren = NodeUtils.collectMapValues(jobNode.getChildren(), originalToCopy);
+                List<Node<?>> newChildren = NodeUtils.collectMapValues(jobNode.getValue(), originalToCopy);
                 CompositeNode nodeCopy = createImmutableCompositeNode(jobNode.getNodeType(), null,
                         newChildren, jobNode.getModificationAction());
                 NodeUtils.fixChildrenRelation(nodeCopy);
                 originalToCopy.put(jobNode, nodeCopy);
             } else {
-                for (Node<?> child : jobNode.getChildren()) {
+                for (Node<?> child : jobNode.getValue()) {
                     if (child instanceof SimpleNode<?>) {
                         originalToCopy.put(child, createImmutableSimpleNode(
                                 child.getNodeType(), null, child.getValue(),
index f1c2a44a03373ee0126595802740b54cff6beb18..65b7608c166a167d05b6fa1e802db9eb7ef2e07c 100644 (file)
@@ -25,19 +25,19 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * @author michal.rehak
- * 
+ *
  */
 public class NodeModificationBuilderImpl implements NodeModificationBuilder {
 
-    private SchemaContext context;
+    private final SchemaContext context;
 
-    private Set<MutableNode<?>> changeLog;
-    private LazyNodeToNodeMap originalToMutable;
+    private final Set<MutableNode<?>> changeLog;
+    private final LazyNodeToNodeMap originalToMutable;
 
     /**
      * @param context
      */
-    public NodeModificationBuilderImpl(SchemaContext context) {
+    public NodeModificationBuilderImpl(final SchemaContext context) {
         this.context = context;
         originalToMutable = new LazyNodeToNodeMap();
         changeLog = new HashSet<>();
@@ -47,55 +47,55 @@ public class NodeModificationBuilderImpl implements NodeModificationBuilder {
      * @param modNode
      * @param action
      */
-    private void addModificationToLog(MutableNode<?> modNode, ModifyAction action) {
+    private void addModificationToLog(final MutableNode<?> modNode, final ModifyAction action) {
         modNode.setModifyAction(action);
         changeLog.add(modNode);
     }
 
     @Override
-    public void addNode(MutableSimpleNode<?> newNode) {
+    public void addNode(final MutableSimpleNode<?> newNode) {
         NodeUtils.fixParentRelation(newNode);
         addModificationToLog(newNode, ModifyAction.CREATE);
     }
 
     @Override
-    public void addNode(MutableCompositeNode newNode) {
+    public void addNode(final MutableCompositeNode newNode) {
         NodeUtils.fixParentRelation(newNode);
         addModificationToLog(newNode, ModifyAction.CREATE);
     }
 
     @Override
-    public void replaceNode(MutableSimpleNode<?> replacementNode) {
+    public void replaceNode(final MutableSimpleNode<?> replacementNode) {
         addModificationToLog(replacementNode, ModifyAction.REPLACE);
     }
 
     @Override
-    public void replaceNode(MutableCompositeNode replacementNode) {
+    public void replaceNode(final MutableCompositeNode replacementNode) {
         addModificationToLog(replacementNode, ModifyAction.REPLACE);
     }
 
     @Override
-    public void deleteNode(MutableCompositeNode deadNode) {
+    public void deleteNode(final MutableCompositeNode deadNode) {
         addModificationToLog(deadNode, ModifyAction.DELETE);
     }
 
     @Override
-    public void deleteNode(MutableSimpleNode<?> deadNode) {
+    public void deleteNode(final MutableSimpleNode<?> deadNode) {
         addModificationToLog(deadNode, ModifyAction.DELETE);
     }
 
     @Override
-    public void removeNode(MutableSimpleNode<?> deadNode) {
+    public void removeNode(final MutableSimpleNode<?> deadNode) {
         addModificationToLog(deadNode, ModifyAction.REMOVE);
     }
 
     @Override
-    public void removeNode(MutableCompositeNode deadNode) {
+    public void removeNode(final MutableCompositeNode deadNode) {
         addModificationToLog(deadNode, ModifyAction.REMOVE);
     }
 
     @Override
-    public void mergeNode(MutableCompositeNode alteredNode) {
+    public void mergeNode(final MutableCompositeNode alteredNode) {
         addModificationToLog(alteredNode, ModifyAction.MERGE);
     }
 
@@ -122,7 +122,7 @@ public class NodeModificationBuilderImpl implements NodeModificationBuilder {
                         // try to add key subnode to wanted list
                         List<QName> supportedKeys = listSchema.getKeyDefinition();
                         CompositeNode outlawOriginal = ((MutableCompositeNode) outlaw).getOriginal();
-                        for (Node<?> outlawOriginalChild : outlawOriginal.getChildren()) {
+                        for (Node<?> outlawOriginalChild : outlawOriginal.getValue()) {
                             if (supportedKeys.contains(outlawOriginalChild.getNodeType())) {
                                 originalToMutable.getMutableEquivalent(outlawOriginalChild);
                             }
@@ -139,7 +139,7 @@ public class NodeModificationBuilderImpl implements NodeModificationBuilder {
      * @param focusedDescendant
      * @return set of parents and focusedAncestor itself
      */
-    private static Set<Node<?>> collectSelfAndAllParents(Node<?> focusedDescendant) {
+    private static Set<Node<?>> collectSelfAndAllParents(final Node<?> focusedDescendant) {
         Set<Node<?>> family = new HashSet<>();
         Node<?> tmpNode = focusedDescendant;
         while (tmpNode != null) {
@@ -154,7 +154,7 @@ public class NodeModificationBuilderImpl implements NodeModificationBuilder {
      * @return mutable version of given node
      */
     @Override
-    public Node<?> getMutableEquivalent(Node<?> originalNode) {
+    public Node<?> getMutableEquivalent(final Node<?> originalNode) {
         return originalToMutable.getMutableEquivalent(originalNode);
     }
 
index 56c814bfde79844310d11fa7b278d00be54a1029..31ab5fdbb2b0f42e822fc7080add4b2f83b404e3 100644 (file)
@@ -23,7 +23,6 @@ import javax.xml.xpath.XPathExpression;
 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;
@@ -40,6 +39,7 @@ import org.w3c.dom.Element;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
 /**
  * @author michal.rehak
@@ -58,7 +58,7 @@ public abstract class NodeUtils {
      * @param node
      * @return node path up till root node
      */
-    public static String buildPath(Node<?> node) {
+    public static String buildPath(final Node<?> node) {
         List<String> breadCrumbs = new ArrayList<>();
         Node<?> tmpNode = node;
         while (tmpNode != null) {
@@ -74,7 +74,7 @@ public abstract class NodeUtils {
      * @return dom tree, containing same node structure, yang nodes are
      *         associated to dom nodes as user data
      */
-    public static org.w3c.dom.Document buildShadowDomTree(CompositeNode treeRootNode) {
+    public static org.w3c.dom.Document buildShadowDomTree(final CompositeNode treeRootNode) {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         org.w3c.dom.Document doc = null;
         try {
@@ -111,7 +111,7 @@ public abstract class NodeUtils {
             jointPlace.appendChild(itemEl);
 
             if (item instanceof CompositeNode) {
-                for (Node<?> child : ((CompositeNode) item).getChildren()) {
+                for (Node<?> child : ((CompositeNode) item).getValue()) {
                     jobQueue.push(new SimpleEntry<org.w3c.dom.Node, Node<?>>(itemEl, child));
                 }
             }
@@ -127,7 +127,7 @@ public abstract class NodeUtils {
      * @throws XPathExpressionException
      */
     @SuppressWarnings("unchecked")
-    public static <T> T findNodeByXpath(org.w3c.dom.Document doc, String xpathEx) throws XPathExpressionException {
+    public static <T> T findNodeByXpath(final org.w3c.dom.Document doc, final String xpathEx) throws XPathExpressionException {
         T userNode = null;
         XPathFactory xPathfactory = XPathFactory.newInstance();
         XPath xpath = xPathfactory.newXPath();
@@ -148,7 +148,7 @@ public abstract class NodeUtils {
      * @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) {
+    public static Map<QName, List<Node<?>>> buildNodeMap(final List<Node<?>> value) {
         Map<QName, List<Node<?>>> nodeMapTmp = Maps.newLinkedHashMap();
         if (value == null) {
             throw new IllegalStateException("nodeList should not be null or empty");
@@ -168,7 +168,7 @@ public abstract class NodeUtils {
      * @param context
      * @return map of lists, where key = path; value = {@link DataSchemaNode}
      */
-    public static Map<String, ListSchemaNode> buildMapOfListNodes(SchemaContext context) {
+    public static Map<String, ListSchemaNode> buildMapOfListNodes(final SchemaContext context) {
         Map<String, ListSchemaNode> mapOfLists = new HashMap<>();
 
         Stack<DataSchemaNode> jobQueue = new Stack<>();
@@ -192,7 +192,7 @@ public abstract class NodeUtils {
      * @param qNamesPath
      * @return path
      */
-    private static String schemaPathToPath(List<QName> qNamesPath) {
+    private static String schemaPathToPath(final List<QName> qNamesPath) {
         List<String> pathSeed = new ArrayList<>();
         for (QName qNameItem : qNamesPath) {
             pathSeed.add(qNameItem.getLocalName());
@@ -205,9 +205,9 @@ public abstract class NodeUtils {
      *
      * @param newNode
      */
-    public static void fixParentRelation(Node<?> newNode) {
+    public static void fixParentRelation(final Node<?> newNode) {
         if (newNode.getParent() != null) {
-            List<Node<?>> siblings = newNode.getParent().getChildren();
+            List<Node<?>> siblings = newNode.getParent().getValue();
             if (!siblings.contains(newNode)) {
                 siblings.add(newNode);
             }
@@ -219,9 +219,9 @@ public abstract class NodeUtils {
      *
      * @param parentNode
      */
-    public static void fixChildrenRelation(CompositeNode parentNode) {
-        if (parentNode.getChildren() != null) {
-            for (Node<?> child : parentNode.getChildren()) {
+    public static void fixChildrenRelation(final CompositeNode parentNode) {
+        if (parentNode.getValue() != null) {
+            for (Node<?> child : parentNode.getValue()) {
                 if (child instanceof AbstractNodeTO<?>) {
                     ((AbstractNodeTO<?>) child).setParent(parentNode);
                 }
@@ -234,7 +234,7 @@ public abstract class NodeUtils {
      * @param dataMap
      * @return list of values of map, found by given keys
      */
-    public static <T, K> List<K> collectMapValues(List<T> keys, Map<T, K> dataMap) {
+    public static <T, K> List<K> collectMapValues(final List<T> keys, final Map<T, K> dataMap) {
         List<K> valueSubList = new ArrayList<>();
         for (T key : keys) {
             valueSubList.add(dataMap.get(key));
@@ -247,7 +247,7 @@ public abstract class NodeUtils {
      * @param nodes
      * @return list of children in list of appropriate type
      */
-    public static List<Node<?>> buildChildrenList(Node<?>... nodes) {
+    public static List<Node<?>> buildChildrenList(final Node<?>... nodes) {
         return Lists.newArrayList(nodes);
     }
 
index ccba69b4b925df413397dd5d4c3babebaa656d0c..c55567987b16ab8ed756cbe7be755f5ea6ad247c 100644 (file)
@@ -36,9 +36,9 @@ import org.opendaylight.yangtools.yang.data.api.SimpleNode;
  * XML as {@link InputStream}. The output of the operation SHOULD be root
  * <code>CompositeNode</code> or <code>SimpleElement</code> depends by which
  * element XML begins. The XML header is omitted by XML parser.
- * 
+ *
  * @author Lukas Sedlak
- * 
+ *
  * @see CompositeNode
  * @see SimpleNode
  * @see Node
@@ -56,7 +56,7 @@ public final class XmlTreeBuilder {
      * output of the operation SHOULD be root <code>CompositeNode</code> or
      * <code>SimpleElement</code> depends on element that XML document begins.
      * The XML header is omitted by XML parser.
-     * 
+     *
      * @param inputStream
      *            XML Input Stream
      * @return root <code>Node</code> element conformant to XML start element in
@@ -91,7 +91,7 @@ public final class XmlTreeBuilder {
                 if (newNode != null) {
                     processingQueue.push(newNode);
                     if (compParentNode != null) {
-                        compParentNode.getChildren().add(newNode);
+                        compParentNode.getValue().add(newNode);
                     }
                 }
             } else if (event.isEndElement()) {
@@ -109,14 +109,14 @@ public final class XmlTreeBuilder {
      * characters value. If the SimpleNode is composed only by empty XML tag
      * (i.e. {@code <emptyTag />} or {@code<emptyTag></emptyTag>}) the result
      * will be also <code>true</code>.
-     * 
+     *
      * @param event
      *            actual XMLEvent that is processed
      * @return <code>true</code> only and only if the XMLEvent Start Element is
      *         Simple element tag and contains character values or is empty XML
      *         tag.
      * @throws XMLStreamException
-     * 
+     *
      * @see SimpleNode
      */
     private static boolean isSimpleNodeEvent(final XMLEvent event) throws XMLStreamException {
@@ -144,13 +144,13 @@ public final class XmlTreeBuilder {
      * contains 1..N XML child elements. (i.e. {@code <compositeNode>
      *         <simpleNode>data</simpleNode>
      * </compositeNode>})
-     * 
+     *
      * @param event
      *            actual XMLEvent that is processed
      * @return <code>true</code> only if XML Element contains 1..N child
      *         elements, otherwise returns <code>false</code>
      * @throws XMLStreamException
-     * 
+     *
      * @see CompositeNode
      */
     private static boolean isCompositeNodeEvent(final XMLEvent event) throws XMLStreamException {
@@ -177,7 +177,7 @@ public final class XmlTreeBuilder {
     /**
      * Creates and returns <code>SimpleNode</code> instance from actually
      * processed XML Start Element.
-     * 
+     *
      * @param startElement
      *            actual XML Start Element that is processed
      * @param parent
@@ -185,11 +185,11 @@ public final class XmlTreeBuilder {
      * @return <code>new SimpleNode</code> instance from actually processed XML
      *         Start Element
      * @throws XMLStreamException
-     * 
+     *
      * @see SimpleNode
      */
     private static SimpleNode<String> resolveSimpleNodeFromStartElement(final StartElement startElement,
-            CompositeNode parent) throws XMLStreamException {
+            final CompositeNode parent) throws XMLStreamException {
         checkArgument(startElement != null, "Start Element cannot be NULL!");
         String data = null;
 
@@ -210,19 +210,19 @@ public final class XmlTreeBuilder {
     /**
      * Creates and returns <code>MutableCompositeNode</code> instance from
      * actually processed XML Start Element.
-     * 
+     *
      * @param startElement
      *            actual XML Start Element that is processed
      * @param parent
      *            Parent CompositeNode
      * @return <code>new MutableCompositeNode</code> instance from actually
      *         processed XML Start Element
-     * 
+     *
      * @see CompositeNode
      * @see MutableCompositeNode
      */
     private static MutableCompositeNode resolveCompositeNodeFromStartElement(final StartElement startElement,
-            CompositeNode parent) {
+            final CompositeNode parent) {
         checkArgument(startElement != null, "Start Element cannot be NULL!");
 
         return NodeFactory.createMutableCompositeNode(resolveElementQName(startElement), parent,
@@ -231,12 +231,12 @@ public final class XmlTreeBuilder {
 
     /**
      * Extract and retrieve XML Element QName to OpenDaylight QName.
-     * 
+     *
      * @param element
      *            Start Element
      * @return QName instance composed of <code>elements</code> Namespace and
      *         Local Part.
-     * 
+     *
      * @see QName
      */
     private static QName resolveElementQName(final StartElement element) {
index 6ffaf20ccc6f231c6af028d635d31a120b1a066b..7b180f96651a8e81aacfc848f3d8364ea67b2da5 100644 (file)
@@ -65,7 +65,7 @@ public class XmlDocumentUtils {
         Element element;
         SchemaContext schemaContext;
 
-        ElementWithSchemaContext(Element element,SchemaContext schemaContext) {
+        ElementWithSchemaContext(final Element element,final SchemaContext schemaContext) {
             this.schemaContext = schemaContext;
             this.element = element;
         }
@@ -82,7 +82,7 @@ public class XmlDocumentUtils {
     private static final XmlCodecProvider DEFAULT_XML_VALUE_CODEC_PROVIDER = new XmlCodecProvider() {
 
         @Override
-        public TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> codecFor(TypeDefinition<?> baseType) {
+        public TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> codecFor(final TypeDefinition<?> baseType) {
             return TypeDefinitionAwareCodec.from(baseType);
         }
     };
@@ -101,7 +101,7 @@ public class XmlDocumentUtils {
      * @return new instance of XML Document
      * @throws UnsupportedDataTypeException
      */
-    public static Document toDocument(CompositeNode data, DataNodeContainer schema, XmlCodecProvider codecProvider)
+    public static Document toDocument(final CompositeNode data, final DataNodeContainer schema, final XmlCodecProvider codecProvider)
             throws UnsupportedDataTypeException {
         Preconditions.checkNotNull(data);
         Preconditions.checkNotNull(schema);
@@ -139,7 +139,7 @@ public class XmlDocumentUtils {
      * @return new instance of XML Document
      * @throws UnsupportedDataTypeException
      */
-    public static Document toDocument(CompositeNode data, XmlCodecProvider codecProvider)
+    public static Document toDocument(final CompositeNode data, final XmlCodecProvider codecProvider)
             throws UnsupportedDataTypeException {
         Preconditions.checkNotNull(data);
 
@@ -157,8 +157,8 @@ public class XmlDocumentUtils {
         return doc;
     }
 
-    private static Element createXmlRootElement(Document doc, Node<?> data, SchemaNode schema,
-            XmlCodecProvider codecProvider) throws UnsupportedDataTypeException {
+    private static Element createXmlRootElement(final Document doc, final Node<?> data, final SchemaNode schema,
+            final XmlCodecProvider codecProvider) throws UnsupportedDataTypeException {
         Element itemEl = createElementFor(doc, data);
         if (data instanceof SimpleNode<?>) {
             if (schema instanceof LeafListSchemaNode) {
@@ -174,7 +174,7 @@ public class XmlDocumentUtils {
                 }
             }
         } else { // CompositeNode
-            for (Node<?> child : ((CompositeNode) data).getChildren()) {
+            for (Node<?> child : ((CompositeNode) data).getValue()) {
                 DataSchemaNode childSchema = null;
                 if (schema != null) {
                     childSchema = findFirstSchemaForNode(child, ((DataNodeContainer) schema).getChildNodes());
@@ -192,7 +192,7 @@ public class XmlDocumentUtils {
         return itemEl;
     }
 
-    public static Element createElementFor(Document doc, Node<?> data) {
+    public static Element createElementFor(final Document doc, final Node<?> data) {
         QName dataType = data.getNodeType();
         Element ret;
         if (dataType.getNamespace() != null) {
@@ -210,15 +210,15 @@ public class XmlDocumentUtils {
         return ret;
     }
 
-    public static void writeValueByType(Element element, SimpleNode<?> node, TypeDefinition<?> type,
-            DataSchemaNode schema, XmlCodecProvider codecProvider) {
+    public static void writeValueByType(final Element element, final SimpleNode<?> node, final TypeDefinition<?> type,
+            final DataSchemaNode schema, final XmlCodecProvider codecProvider) {
 
         Object nodeValue = node.getValue();
 
         writeValueByType(element, type, codecProvider, nodeValue);
     }
 
-    public static void writeValueByType(Element element, TypeDefinition<?> type, XmlCodecProvider codecProvider, Object nodeValue) {
+    public static void writeValueByType(final Element element, final TypeDefinition<?> type, final XmlCodecProvider codecProvider, final Object nodeValue) {
         TypeDefinition<?> baseType = resolveBaseTypeFrom(type);
         if (baseType instanceof IdentityrefTypeDefinition) {
             if (nodeValue instanceof QName) {
@@ -269,7 +269,7 @@ public class XmlDocumentUtils {
     }
 
 
-    public final static TypeDefinition<?> resolveBaseTypeFrom(TypeDefinition<?> type) {
+    public final static TypeDefinition<?> resolveBaseTypeFrom(final TypeDefinition<?> type) {
         TypeDefinition<?> superType = type;
         while (superType.getBaseType() != null) {
             superType = superType.getBaseType();
@@ -277,7 +277,7 @@ public class XmlDocumentUtils {
         return superType;
     }
 
-    private static final DataSchemaNode findFirstSchemaForNode(Node<?> node, Set<DataSchemaNode> dataSchemaNode) {
+    private static final DataSchemaNode findFirstSchemaForNode(final Node<?> node, final Set<DataSchemaNode> dataSchemaNode) {
         if (dataSchemaNode != null && node != null) {
             for (DataSchemaNode dsn : dataSchemaNode) {
                 if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
@@ -295,28 +295,28 @@ public class XmlDocumentUtils {
         return null;
     }
 
-    public static Node<?> toDomNode(Element xmlElement, Optional<DataSchemaNode> schema,
-            Optional<XmlCodecProvider> codecProvider) {
+    public static Node<?> toDomNode(final Element xmlElement, final Optional<DataSchemaNode> schema,
+            final Optional<XmlCodecProvider> codecProvider) {
         if (schema.isPresent()) {
             return toNodeWithSchema(xmlElement, schema.get(), codecProvider.or(DEFAULT_XML_VALUE_CODEC_PROVIDER));
         }
         return toDomNode(xmlElement);
     }
 
-    public static CompositeNode fromElement(Element xmlElement) {
+    public static CompositeNode fromElement(final Element xmlElement) {
         CompositeNodeBuilder<ImmutableCompositeNode> node = ImmutableCompositeNode.builder();
         node.setQName(qNameFromElement(xmlElement));
 
         return node.toInstance();
     }
 
-    public static QName qNameFromElement(Element xmlElement) {
+    public static QName qNameFromElement(final Element xmlElement) {
         String namespace = xmlElement.getNamespaceURI();
         String localName = xmlElement.getLocalName();
         return QName.create(namespace != null ? URI.create(namespace) : null, null, localName);
     }
 
-    private static Node<?> toNodeWithSchema(Element xmlElement, DataSchemaNode schema, XmlCodecProvider codecProvider,SchemaContext schemaCtx) {
+    private static Node<?> toNodeWithSchema(final Element xmlElement, final DataSchemaNode schema, final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) {
         checkQName(xmlElement, schema.getQName());
         if (schema instanceof DataNodeContainer) {
             return toCompositeNodeWithSchema(xmlElement, schema.getQName(), (DataNodeContainer) schema, codecProvider,schemaCtx);
@@ -328,12 +328,12 @@ public class XmlDocumentUtils {
         return null;
     }
 
-    private static Node<?> toNodeWithSchema(Element xmlElement, DataSchemaNode schema, XmlCodecProvider codecProvider) {
+    private static Node<?> toNodeWithSchema(final Element xmlElement, final DataSchemaNode schema, final XmlCodecProvider codecProvider) {
         return toNodeWithSchema(xmlElement, schema, codecProvider, null);
     }
 
-    protected static Node<?> toSimpleNodeWithType(Element xmlElement, LeafSchemaNode schema,
-            XmlCodecProvider codecProvider,SchemaContext schemaCtx) {
+    protected static Node<?> toSimpleNodeWithType(final Element xmlElement, final LeafSchemaNode schema,
+            final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) {
         TypeDefinitionAwareCodec<? extends Object, ? extends TypeDefinition<?>> codec = codecProvider.codecFor(schema.getType());
         String text = xmlElement.getTextContent();
         Object value = null;
@@ -355,8 +355,8 @@ public class XmlDocumentUtils {
         return new SimpleNodeTOImpl<>(schema.getQName(), null, value, modifyAction.orNull());
     }
 
-    private static Node<?> toSimpleNodeWithType(Element xmlElement, LeafListSchemaNode schema,
-            XmlCodecProvider codecProvider,SchemaContext schemaCtx) {
+    private static Node<?> toSimpleNodeWithType(final Element xmlElement, final LeafListSchemaNode schema,
+            final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) {
         TypeDefinitionAwareCodec<? extends Object, ? extends TypeDefinition<?>> codec = codecProvider.codecFor(schema.getType());
         String text = xmlElement.getTextContent();
         Object value = null;
@@ -374,8 +374,8 @@ public class XmlDocumentUtils {
         return new SimpleNodeTOImpl<>(schema.getQName(), null, value, modifyAction.orNull());
     }
 
-    private static Node<?> toCompositeNodeWithSchema(Element xmlElement, QName qName, DataNodeContainer schema,
-            XmlCodecProvider codecProvider,SchemaContext schemaCtx) {
+    private static Node<?> toCompositeNodeWithSchema(final Element xmlElement, final QName qName, final DataNodeContainer schema,
+            final XmlCodecProvider codecProvider,final SchemaContext schemaCtx) {
         List<Node<?>> values = toDomNodes(xmlElement, Optional.fromNullable(schema.getChildNodes()),schemaCtx);
         Optional<ModifyAction> modifyAction = getModifyOperationFromAttributes(xmlElement);
         return ImmutableCompositeNode.create(qName, values, modifyAction.orNull());
@@ -383,10 +383,11 @@ public class XmlDocumentUtils {
 
     public static final QName OPERATION_ATTRIBUTE_QNAME = QName.create(URI.create("urn:ietf:params:xml:ns:netconf:base:1.0"), null, "operation");
 
-    public static Optional<ModifyAction> getModifyOperationFromAttributes(Element xmlElement) {
+    public static Optional<ModifyAction> getModifyOperationFromAttributes(final Element xmlElement) {
         Attr attributeNodeNS = xmlElement.getAttributeNodeNS(OPERATION_ATTRIBUTE_QNAME.getNamespace().toString(), OPERATION_ATTRIBUTE_QNAME.getLocalName());
-        if(attributeNodeNS == null)
-            return Optional.absent();
+        if(attributeNodeNS == null) {
+                       return Optional.absent();
+               }
 
         ModifyAction action = ModifyAction.fromXmlValue(attributeNodeNS.getValue());
         Preconditions.checkArgument(action.isOnElementPermitted(), "Unexpected operation %s on %s", action, xmlElement);
@@ -394,12 +395,12 @@ public class XmlDocumentUtils {
         return Optional.of(action);
     }
 
-    private static void checkQName(Element xmlElement, QName qName) {
+    private static void checkQName(final Element xmlElement, final QName qName) {
         checkState(Objects.equal(xmlElement.getNamespaceURI(), qName.getNamespace().toString()));
         checkState(qName.getLocalName().equals(xmlElement.getLocalName()));
     }
 
-    public static final Optional<DataSchemaNode> findFirstSchema(QName qname, Set<DataSchemaNode> dataSchemaNode) {
+    public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Set<DataSchemaNode> dataSchemaNode) {
         if (dataSchemaNode != null && !dataSchemaNode.isEmpty() && qname != null) {
             for (DataSchemaNode dsn : dataSchemaNode) {
                 if (qname.isEqualWithoutRevision(dsn.getQName())) {
@@ -417,11 +418,11 @@ public class XmlDocumentUtils {
         return Optional.absent();
     }
 
-    public static Node<?> toDomNode(Document doc) {
+    public static Node<?> toDomNode(final Document doc) {
         return toDomNode(doc.getDocumentElement());
     }
 
-    private static Node<?> toDomNode(Element element) {
+    private static Node<?> toDomNode(final Element element) {
         QName qname = qNameFromElement(element);
 
         ImmutableList.Builder<Node<?>> values = ImmutableList.<Node<?>> builder();
@@ -447,11 +448,11 @@ public class XmlDocumentUtils {
         return ImmutableCompositeNode.create(qname, values.build());
     }
 
-    public static List<Node<?>> toDomNodes(final Element element, final Optional<Set<DataSchemaNode>> context,SchemaContext schemaCtx) {
+    public static List<Node<?>> toDomNodes(final Element element, final Optional<Set<DataSchemaNode>> context,final SchemaContext schemaCtx) {
         return forEachChild(element.getChildNodes(),schemaCtx, new Function<ElementWithSchemaContext, Optional<Node<?>>>() {
 
             @Override
-            public Optional<Node<?>> apply(ElementWithSchemaContext input) {
+            public Optional<Node<?>> apply(final ElementWithSchemaContext input) {
                 if (context.isPresent()) {
                     QName partialQName = qNameFromElement(input.getElement());
                     Optional<DataSchemaNode> schemaNode = findFirstSchema(partialQName, context.get());
@@ -493,7 +494,7 @@ public class XmlDocumentUtils {
      *         Element with equal notification QName defined in XML Document.
      */
     public static CompositeNode notificationToDomNodes(final Document document,
-            final Optional<Set<NotificationDefinition>> notifications, SchemaContext schemaCtx) {
+            final Optional<Set<NotificationDefinition>> notifications, final SchemaContext schemaCtx) {
         if (notifications.isPresent() && (document != null) && (document.getDocumentElement() != null)) {
             final NodeList originChildNodes = document.getDocumentElement().getChildNodes();
             for (int i = 0; i < originChildNodes.getLength(); i++) {
@@ -532,7 +533,7 @@ public class XmlDocumentUtils {
         return Optional.<NotificationDefinition>absent();
     }
 
-    private static final <T> List<T> forEachChild(NodeList nodes, SchemaContext schemaContext, Function<ElementWithSchemaContext, Optional<T>> forBody) {
+    private static final <T> List<T> forEachChild(final NodeList nodes, final SchemaContext schemaContext, final Function<ElementWithSchemaContext, Optional<T>> forBody) {
         ImmutableList.Builder<T> ret = ImmutableList.<T> builder();
         for (int i = 0; i < nodes.getLength(); i++) {
             org.w3c.dom.Node child = nodes.item(i);
index 6ac17cdc03290ac6eb15552e1abdc0fa67301624..209f3665b708eeaee3e9d677d4cacbfac08da12a 100644 (file)
@@ -61,8 +61,8 @@ public class LazyNodeToNodeMapTest {
         Assert.assertEquals(2, lazyN2N.getKeyNodes().size());
 
         Assert.assertEquals(mutableTree, subMutant.getParent());
-        Assert.assertEquals(mutableTree.getChildren().size(), 1);
-        Assert.assertEquals(mutableTree.getChildren().iterator().next(), subMutant);
+        Assert.assertEquals(mutableTree.getValue().size(), 1);
+        Assert.assertEquals(mutableTree.getValue().iterator().next(), subMutant);
     }
 
     /**
index d9531d4225218fda7f293402a41ac145fb8869ee..9c58b9f92bfe5f813424d85fd9c342af6b5ad458 100644 (file)
@@ -34,15 +34,15 @@ public class MyNodeBuilder extends BuilderSupport {
             .getLogger(MyNodeBuilder.class);
 
     private URI qnNamespace;
-    private String qnPrefix;
-    private Date qnRevision;
+    private final String qnPrefix;
+    private final Date qnRevision;
 
     private CompositeNode rootNode;
 
        /**
         * @param baseQName
         */
-       private MyNodeBuilder(QName baseQName) {
+       private MyNodeBuilder(final QName baseQName) {
                qnNamespace = baseQName.getNamespace();
                qnPrefix = baseQName.getPrefix();
                qnRevision = baseQName.getRevision();
@@ -64,7 +64,7 @@ public class MyNodeBuilder extends BuilderSupport {
     }
 
     @Override
-    protected void setParent(Object parent, Object child) {
+    protected void setParent(final Object parent, final Object child) {
        // do nothing
         if (child instanceof AbstractNodeTO<?>) {
             ((AbstractNodeTO<?>) child).setParent((CompositeNode) parent);
@@ -74,7 +74,7 @@ public class MyNodeBuilder extends BuilderSupport {
     }
 
     @Override
-    protected Object createNode(Object name) {
+    protected Object createNode(final Object name) {
         MutableCompositeNode newNode = NodeFactory.createMutableCompositeNode(
                 createQName(name), getCurrentNode(), null, null, null);
         NodeUtils.fixParentRelation(newNode);
@@ -82,7 +82,7 @@ public class MyNodeBuilder extends BuilderSupport {
     }
 
     @Override
-    protected Object createNode(Object name, @SuppressWarnings("rawtypes") Map attributes) {
+    protected Object createNode(final Object name, @SuppressWarnings("rawtypes") final Map attributes) {
         ModifyAction modifyAction = processAttributes(attributes);
         MutableCompositeNode newNode = NodeFactory.createMutableCompositeNode(
                 createQName(name), getCurrentNode(), null, modifyAction, null);
@@ -92,7 +92,7 @@ public class MyNodeBuilder extends BuilderSupport {
 
 
     @Override
-    protected Object createNode(Object name, @SuppressWarnings("rawtypes") Map attributes, Object value) {
+    protected Object createNode(final Object name, @SuppressWarnings("rawtypes") final Map attributes, final Object value) {
         ModifyAction modifyAction = processAttributes(attributes);
         SimpleNode<Object> newNode = NodeFactory.createImmutableSimpleNode(
                 createQName(name), (CompositeNode) getCurrent(), value, modifyAction);
@@ -104,7 +104,7 @@ public class MyNodeBuilder extends BuilderSupport {
      * @param attributes
      * @return
      */
-    private ModifyAction processAttributes(@SuppressWarnings("rawtypes") Map attributes) {
+    private ModifyAction processAttributes(@SuppressWarnings("rawtypes") final Map attributes) {
         LOG.debug("attributes:" + attributes);
         ModifyAction modAction = null;
 
@@ -131,13 +131,13 @@ public class MyNodeBuilder extends BuilderSupport {
     }
 
     @Override
-    protected Object createNode(Object name, Object value) {
+    protected Object createNode(final Object name, final Object value) {
         SimpleNode<Object> newNode = NodeFactory.createImmutableSimpleNode(createQName(name), (CompositeNode) getCurrent(), value);
         NodeUtils.fixParentRelation(newNode);
         return newNode;
     }
 
-    private QName createQName(Object localName) {
+    private QName createQName(final Object localName) {
        LOG.debug("qname for: "+localName);
            return new QName(qnNamespace, qnRevision, qnPrefix, (String) localName);
     }
@@ -157,7 +157,7 @@ public class MyNodeBuilder extends BuilderSupport {
     }
 
        @Override
-       protected Object postNodeCompletion(Object parent, Object node) {
+       protected Object postNodeCompletion(final Object parent, final Object node) {
            Node<?> nodeRevisited = (Node<?>) node;
            LOG.debug("postNodeCompletion at: \n  "+ nodeRevisited+"\n  "+parent);
            if (nodeRevisited instanceof MutableCompositeNode) {
@@ -173,7 +173,7 @@ public class MyNodeBuilder extends BuilderSupport {
                    rootNode = (CompositeNode) nodeRevisited;
                } else {
                    NodeUtils.fixParentRelation(nodeRevisited);
-                   nodeRevisited.getParent().getChildren().remove(mutant);
+                   nodeRevisited.getParent().getValue().remove(mutant);
                }
            }
 
index 9b5edc99eacc85a8f490ffc17828e64e472ae0c4..ed6d709c35216a6a61768a3dba23784752835d1c 100644 (file)
@@ -60,7 +60,7 @@ public class NodeFactoryTest {
      */
     @Test
     public void testImmutableNodes() throws Exception {
-        Assert.assertEquals(2, network.getChildren().size());
+        Assert.assertEquals(2, network.getValue().size());
         CompositeNode tpList = NodeUtils.findNodeByXpath(networkShadow,
                 NodeHelper.AddNamespaceToPattern(
                         "//{0}node[{0}node-id/text()='nodeId_19']/{0}termination-points", ns));
@@ -120,7 +120,7 @@ public class NodeFactoryTest {
         Document shadowConfig = NodeUtils.buildShadowDomTree(root);
         NodeHelper.compareXmlTree(shadowConfig, "./mutableNodesConfig.xml", getClass());
 
-        Assert.assertEquals(1, root.getChildren().size());
+        Assert.assertEquals(1, root.getValue().size());
         Assert.assertEquals(1, ifNode.getSimpleNodesByName("name").size());
         Assert.assertEquals(1, ifNode.getSimpleNodesByName("mtu").size());
         Assert.assertEquals(2, topNode.getCompositesByName("interface").size());
index eb5df99258489456910f640680c33664fc03955b..02fe73d2abbd20e61ffca36f707f2b369621992a 100644 (file)
@@ -129,7 +129,7 @@ public abstract class NodeHelper {
       "    </network-elements>\n" +
       "</network>";
 
-    private static String domTreeString(Document domTree) throws TransformerException {
+    private static String domTreeString(final Document domTree) throws TransformerException {
         TransformerFactory transformerFact = TransformerFactory.newInstance();
         transformerFact.setAttribute("indent-number", 4);
         Transformer transformer = transformerFact.newTransformer();
@@ -146,11 +146,11 @@ public abstract class NodeHelper {
      * @param out
      * @throws Exception
      */
-    private static void dumpDoc(Document domTree, PrintStream out) throws Exception {
+    private static void dumpDoc(final Document domTree, final PrintStream out) throws Exception {
       out.println(domTreeString(domTree));
     }
 
-       public static void dumpDoc(Document domTree, Logger logger) throws TransformerException {
+       public static void dumpDoc(final Document domTree, final Logger logger) throws TransformerException {
                logger.info("{}", domTreeString(domTree));
        }
 
@@ -158,7 +158,7 @@ public abstract class NodeHelper {
      * @param qName
      * @return example tree, see {@link #NETWORK_XML}
      */
-    public static CompositeNode buildTestConfigTree(QName qName) {
+    public static CompositeNode buildTestConfigTree(final QName qName) {
         List<Node<?>> value = new ArrayList<Node<?>>();
         value.add(NodeFactory.createImmutableSimpleNode(new QName(qName, "element-id"), null, "ntElementId_09"));
         CompositeNode ntElementNode1 = NodeFactory.createImmutableCompositeNode(new QName(qName, "network-element"), null, value);
@@ -330,8 +330,8 @@ public abstract class NodeHelper {
     /**
      * @param parentNode
      */
-    public static void assignParentToChildren(CompositeNode parentNode) {
-        for (Node<?> child : parentNode.getChildren()) {
+    public static void assignParentToChildren(final CompositeNode parentNode) {
+        for (Node<?> child : parentNode.getValue()) {
             ((AbstractNodeTO<?>) child).setParent(parentNode);
         }
     }
@@ -356,7 +356,7 @@ public abstract class NodeHelper {
      * @return tree root
      * @throws Exception
      */
-    public static CompositeNode loadConfigByGroovy(String scriptName) throws Exception {
+    public static CompositeNode loadConfigByGroovy(final String scriptName) throws Exception {
        InputStream configStream = NodeHelper.class.getResourceAsStream(scriptName);
        Binding binding = new Binding();
        GroovyShell gShell = new GroovyShell(binding);
@@ -378,7 +378,7 @@ public abstract class NodeHelper {
      * @param nsArg , e.g.: <pre>{"uri:ns1", "uri:ns2"}</pre>
      * @return pattern with namespaces: <pre>//uri:ns1:network/uri:ns2:xx[text() = ''sss'']"</pre>
      */
-    public static String AddNamespaceToPattern(String pattern, Object... nsArg) {
+    public static String AddNamespaceToPattern(final String pattern, final Object... nsArg) {
         Object[] ns = nsArg;
         String patternNs = pattern.replaceAll("'", "''");
         if (ns == null) {
@@ -399,7 +399,7 @@ public abstract class NodeHelper {
      * @throws SAXException
      * @throws IOException
      */
-    public static void compareXmlTree(Document tree, String xmlFile, Class<?> clazz) throws Exception,
+    public static void compareXmlTree(final Document tree, final String xmlFile, final Class<?> clazz) throws Exception,
             SAXException, IOException {
         ByteArrayOutputStream actualRaw = new ByteArrayOutputStream();
         dumpDoc(tree, new PrintStream(actualRaw));
index cccb7837be2f0c5076d11c68f9fc93f4532bcdad..285cdb0b30705e3128c76fe282a91586b62fbad7 100644 (file)
@@ -111,7 +111,7 @@ public class NodeUtilsTest {
         CompositeNode topology = network.getCompositesByName("topologies").iterator().next()
             .getCompositesByName("topology").iterator().next();
 
-        Map<QName, List<Node<?>>> nodeMap = NodeUtils.buildNodeMap(topology.getChildren());
+        Map<QName, List<Node<?>>> nodeMap = NodeUtils.buildNodeMap(topology.getValue());
         Assert.assertEquals(3, nodeMap.size());
     }
 
@@ -144,13 +144,13 @@ public class NodeUtilsTest {
        NodeHelper.compareXmlTree(shadowTree, "./config02g-shadow.xml", getClass());
     }
 
-    private static void checkFamilyBinding(CompositeNode treeRoot) throws Exception {
+    private static void checkFamilyBinding(final CompositeNode treeRoot) throws Exception {
         Stack<CompositeNode> jobQueue = new Stack<>();
         jobQueue.push(treeRoot);
 
         while (!jobQueue.isEmpty()) {
             CompositeNode job = jobQueue.pop();
-            for (Node<?> child : job.getChildren()) {
+            for (Node<?> child : job.getValue()) {
                 if (child instanceof CompositeNode) {
                     jobQueue.push((CompositeNode) child);
                 }
index b302c84b9974aef69eb172ca1b497515646efd11..0d7445da70f4b38b8fcf091b50f808b9b9d070fd 100644 (file)
@@ -34,10 +34,10 @@ import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 public class XmlTreeBuilderTest {
 
        private InputStream inputStream;
-       
+
        /**
         * Perform pre-test initialization
-        * 
+        *
         * @throws Exception
         */
        @Before
@@ -61,42 +61,42 @@ public class XmlTreeBuilderTest {
                }
                assertNotNull(rootNode);
                assertTrue(rootNode instanceof CompositeNode);
-               
+
                CompositeNode compRootNode = (CompositeNode)rootNode;
-               assertNotNull(compRootNode.getChildren());
-               
+               assertNotNull(compRootNode.getValue());
+
                SimpleNode<String> methodName = null;
                SimpleNode<String> emptyTag = null;
                CompositeNode params = null;
-               for (final Node<?> childNode : compRootNode.getChildren()) {
+               for (final Node<?> childNode : compRootNode.getValue()) {
                        if (childNode instanceof SimpleNode) {
                                if ("emptyTag".equals(childNode.getNodeType().getLocalName())) {
                                        emptyTag = (SimpleNode<String>) childNode;
                                } else if ("methodName".equals(childNode.getNodeType().getLocalName())) {
                                        methodName = (SimpleNode<String>) childNode;
                                }
-                               
+
                        } else if (childNode instanceof CompositeNode) {
                                params = (CompositeNode) childNode;
                        }
                }
-               
+
                assertNotNull(methodName);
                assertNotNull(params);
                assertTrue(emptyTag.getValue().isEmpty());
                assertEquals(methodName.getValue(), "getDeviceEquipment");
-               
+
                String deviceId = null;
                String deviceIP = null;
-               for (final Node<?> param : params.getChildren()) {
+               for (final Node<?> param : params.getValue()) {
                        if (param instanceof CompositeNode) {
-                               final Node<?> valueNode = ((CompositeNode) param).getChildren().get(0);
-                               
+                               final Node<?> valueNode = ((CompositeNode) param).getValue().get(0);
+
                                assertTrue(valueNode instanceof CompositeNode);
                                final CompositeNode value = (CompositeNode) valueNode;
-                               final Node<?> stringNode = value.getChildren().get(0);
+                               final Node<?> stringNode = value.getValue().get(0);
                                assertTrue(stringNode instanceof SimpleNode);
-                               
+
                                final SimpleNode<String> string = (SimpleNode<String>) stringNode;
                                if ("DeviceID123".equals(string.getValue())) {
                                        deviceId = string.getValue();
@@ -105,11 +105,11 @@ public class XmlTreeBuilderTest {
                                }
                        }
                }
-               
+
                assertNotNull(deviceId);
                assertNotNull(deviceIP);
        }
-       
+
        @Test
        public void nodeMapInCompositeNodeTest() {
            Node<?> rootNode = null;
@@ -118,7 +118,7 @@ public class XmlTreeBuilderTest {
             } catch (XMLStreamException e) {
                     e.printStackTrace();
             }
-            
+
             CompositeNode compRootNode = (CompositeNode)rootNode;
             List<CompositeNode> params = compRootNode.getCompositesByName("params");
             assertEquals(1, params.size());