Replaced 'controller' with 'yangtools' in all package names.
[yangtools.git] / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / NodeFactory.java
similarity index 82%
rename from yang-data-impl/src/main/java/org/opendaylight/controller/yang/data/impl/NodeFactory.java
rename to yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/NodeFactory.java
index 8e6e77498baec6a607957d07984df37339059e01..5e944577628fc778b809221817b5e0405e203f48 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
  */\r
-package org.opendaylight.controller.yang.data.impl;\r
+package org.opendaylight.yangtools.yang.data.impl;\r
 \r
 import java.util.AbstractMap.SimpleEntry;\r
 import java.util.ArrayList;\r
@@ -15,18 +15,18 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.Stack;\r
 \r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-import org.opendaylight.controller.yang.data.api.ModifyAction;\r
-import org.opendaylight.controller.yang.data.api.MutableCompositeNode;\r
-import org.opendaylight.controller.yang.data.api.MutableSimpleNode;\r
-import org.opendaylight.controller.yang.data.api.Node;\r
-import org.opendaylight.controller.yang.data.api.NodeModification;\r
-import org.opendaylight.controller.yang.data.api.SimpleNode;\r
+import org.opendaylight.yangtools.yang.common.QName;\r
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;\r
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;\r
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;\r
+import org.opendaylight.yangtools.yang.data.api.Node;\r
+import org.opendaylight.yangtools.yang.data.api.NodeModification;\r
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;\r
 \r
 /**\r
  * @author michal.rehak\r
- * \r
+ *\r
  */\r
 public abstract class NodeFactory {\r
 \r
@@ -40,24 +40,24 @@ public abstract class NodeFactory {
             CompositeNode parent, T value) {\r
         return createImmutableSimpleNode(qName, parent, value, null);\r
     }\r
-    \r
+\r
     /**\r
      * @param qName\r
      * @param parent\r
      * @param value\r
-     * @param modifyAction \r
+     * @param modifyAction\r
      * @param original originating node, if available\r
      * @return simple node modification, based on given qname, value and parent\r
      */\r
     public static <T> MutableSimpleNode<T> createMutableSimpleNode(QName qName,\r
             CompositeNode parent, Object value, ModifyAction modifyAction, SimpleNode<T> original) {\r
         @SuppressWarnings("unchecked")\r
-        MutableSimpleNodeTOImpl<T> simpleNodeTOImpl = \r
+        MutableSimpleNodeTOImpl<T> simpleNodeTOImpl =\r
                 new MutableSimpleNodeTOImpl<T>(qName, parent, (T) value, modifyAction);\r
         simpleNodeTOImpl.setOriginal(original);\r
         return simpleNodeTOImpl;\r
     }\r
-    \r
+\r
     /**\r
      * @param qName\r
      * @param parent\r
@@ -68,12 +68,12 @@ public abstract class NodeFactory {
             CompositeNode parent, List<Node<?>> value) {\r
         return createImmutableCompositeNode(qName, parent, value, null);\r
     }\r
-    \r
+\r
     /**\r
      * @param qName\r
      * @param parent\r
-     * @param valueArg \r
-     * @param modifyAction \r
+     * @param valueArg\r
+     * @param modifyAction\r
      * @param original originating node, if available\r
      * @return composite node modification, based on given qName, value (children), parent and modifyAction\r
      */\r
@@ -83,13 +83,13 @@ public abstract class NodeFactory {
         if (value == null) {\r
             value = new ArrayList<>();\r
         }\r
-        MutableCompositeNodeTOImpl compositeNodeTOImpl = \r
+        MutableCompositeNodeTOImpl compositeNodeTOImpl =\r
                 new MutableCompositeNodeTOImpl(qName, parent, value, modifyAction);\r
         compositeNodeTOImpl.setOriginal(original);\r
         return compositeNodeTOImpl;\r
     }\r
-    \r
-    \r
+\r
+\r
     /**\r
      * @param qName\r
      * @param parent\r
@@ -99,7 +99,7 @@ public abstract class NodeFactory {
      */\r
     public static <T> SimpleNode<T> createImmutableSimpleNode(QName qName,\r
             CompositeNode parent, T value, ModifyAction modifyAction) {\r
-        SimpleNodeTOImpl<T> simpleNodeModTOImpl = \r
+        SimpleNodeTOImpl<T> simpleNodeModTOImpl =\r
                 new SimpleNodeTOImpl<T>(qName, parent, value, modifyAction);\r
         return simpleNodeModTOImpl;\r
     }\r
@@ -108,43 +108,43 @@ public abstract class NodeFactory {
      * @param qName\r
      * @param parent\r
      * @param value\r
-     * @param modifyAction \r
+     * @param modifyAction\r
      * @return composite node modification, based on given qname, value (children), parent and modifyAction\r
      */\r
     public static CompositeNode createImmutableCompositeNode(QName qName,\r
             CompositeNode parent, List<Node<?>> value, ModifyAction modifyAction) {\r
-        CompositeNodeTOImpl compositeNodeModTOImpl = \r
+        CompositeNodeTOImpl compositeNodeModTOImpl =\r
                 new CompositeNodeTOImpl(qName, parent, value, modifyAction);\r
         return compositeNodeModTOImpl;\r
     }\r
 \r
     /**\r
      * @param node\r
-     * @return copy of given node, parent and value are the same, but parent \r
-     * has no reference to this copy \r
+     * @return copy of given node, parent and value are the same, but parent\r
+     * has no reference to this copy\r
      */\r
     public static <T> SimpleNode<T> copyNode(SimpleNode<T> node) {\r
         SimpleNode<T> twinNode = createImmutableSimpleNode(\r
                     node.getNodeType(), node.getParent(), node.getValue());\r
         return twinNode;\r
     }\r
-    \r
+\r
     /**\r
      * @param node\r
-     * @return copy of given node, parent and value are the same, but parent \r
-     * has no reference to this copy \r
+     * @return copy of given node, parent and value are the same, but parent\r
+     * has no reference to this copy\r
      */\r
     public static <T> MutableSimpleNode<T> copyNodeAsMutable(SimpleNode<T> node) {\r
         MutableSimpleNode<T> twinNode = createMutableSimpleNode(\r
-                    node.getNodeType(), node.getParent(), node.getValue(), \r
+                    node.getNodeType(), node.getParent(), node.getValue(),\r
                     node.getModificationAction(), null);\r
         return twinNode;\r
     }\r
-    \r
+\r
     /**\r
      * @param node\r
-     * @param children \r
-     * @return copy of given node, parent and children are the same, but parent and children \r
+     * @param children\r
+     * @return copy of given node, parent and children are the same, but parent and children\r
      * have no reference to this copy\r
      */\r
     public static CompositeNode copyNode(CompositeNode node, Node<?>... children) {\r
@@ -152,31 +152,31 @@ public abstract class NodeFactory {
                 node.getNodeType(), node.getParent(), Arrays.asList(children), node.getModificationAction());\r
         return twinNode;\r
     }\r
-    \r
+\r
     /**\r
      * @param node\r
-     * @return copy of given node, parent and children are the same, but parent and children \r
+     * @return copy of given node, parent and children are the same, but parent and children\r
      * have no reference to this copy\r
      */\r
     public static CompositeNode copyNode(CompositeNode node) {\r
        return copyNode(node, node.getChildren().toArray(new Node<?>[0]));\r
     }\r
-    \r
+\r
     /**\r
      * @param node root of original tree\r
-     * @param originalToCopyArg (optional) empty map, where binding between original and copy \r
+     * @param originalToCopyArg (optional) empty map, where binding between original and copy\r
      * will be stored\r
      * @return copy of given node and all subnodes recursively\r
      */\r
-    public static MutableCompositeNode copyDeepAsMutable(CompositeNode node, \r
+    public static MutableCompositeNode copyDeepAsMutable(CompositeNode node,\r
             Map<Node<?>, Node<?>> originalToCopyArg) {\r
-        \r
+\r
         Map<Node<?>, Node<?>> originalToCopy = originalToCopyArg;\r
         if (originalToCopy == null) {\r
             originalToCopy = new HashMap<>();\r
         }\r
 \r
-        MutableCompositeNode mutableRoot = createMutableCompositeNode(node.getNodeType(), null, null, \r
+        MutableCompositeNode mutableRoot = createMutableCompositeNode(node.getNodeType(), null, null,\r
                 node.getModificationAction(), null);\r
         Stack<SimpleEntry<CompositeNode, MutableCompositeNode>> jobQueue = new Stack<>();\r
         jobQueue.push(new SimpleEntry<CompositeNode, MutableCompositeNode>(node, mutableRoot));\r
@@ -191,16 +191,16 @@ public abstract class NodeFactory {
             for (Node<?> child : originalNode.getChildren()) {\r
                 Node<?> mutableAscendant = null;\r
                 if (child instanceof CompositeNode) {\r
-                    MutableCompositeNode newMutable = \r
-                            createMutableCompositeNode(child.getNodeType(), mutableNode, null, \r
+                    MutableCompositeNode newMutable =\r
+                            createMutableCompositeNode(child.getNodeType(), mutableNode, null,\r
                                     ((NodeModification) child).getModificationAction(), null);\r
                     jobQueue.push(new SimpleEntry<CompositeNode, MutableCompositeNode>(\r
                             (CompositeNode) child, newMutable));\r
                     mutableAscendant = newMutable;\r
                 } else if (child instanceof SimpleNode<?>) {\r
-                    mutableAscendant = \r
-                            createMutableSimpleNode(child.getNodeType(), mutableNode, \r
-                                    child.getValue(), \r
+                    mutableAscendant =\r
+                            createMutableSimpleNode(child.getNodeType(), mutableNode,\r
+                                    child.getValue(),\r
                                     ((NodeModification) child).getModificationAction(), null);\r
                 } else {\r
                     throw new IllegalStateException("Node class deep copy not supported: "\r
@@ -215,30 +215,30 @@ public abstract class NodeFactory {
 \r
         return mutableRoot;\r
     }\r
-    \r
+\r
     /**\r
      * @param node root of original tree\r
-     * @param originalToCopyArg (optional) empty map, where binding between original and copy \r
+     * @param originalToCopyArg (optional) empty map, where binding between original and copy\r
      * will be stored\r
      * @return copy of given node and all subnodes recursively\r
      */\r
-    public static CompositeNode copyDeepAsImmutable(CompositeNode node, \r
+    public static CompositeNode copyDeepAsImmutable(CompositeNode node,\r
             Map<Node<?>, Node<?>> originalToCopyArg) {\r
         Stack<CompositeNode> jobQueue = new Stack<>();\r
         jobQueue.push(node);\r
-        \r
+\r
         Map<Node<?>, Node<?>> originalToCopy = originalToCopyArg;\r
         if (originalToCopy == null) {\r
             originalToCopy = new HashMap<>();\r
         }\r
-        \r
+\r
         while (!jobQueue.isEmpty()) {\r
             CompositeNode jobNode = jobQueue.peek();\r
-            if (!originalToCopy.isEmpty() \r
+            if (!originalToCopy.isEmpty()\r
                     && originalToCopy.keySet().containsAll(jobNode.getChildren())) {\r
                 jobQueue.pop();\r
                 List<Node<?>> newChildren = NodeUtils.collectMapValues(jobNode.getChildren(), originalToCopy);\r
-                CompositeNode nodeCopy = createImmutableCompositeNode(jobNode.getNodeType(), null, \r
+                CompositeNode nodeCopy = createImmutableCompositeNode(jobNode.getNodeType(), null,\r
                         newChildren, jobNode.getModificationAction());\r
                 NodeUtils.fixChildrenRelation(nodeCopy);\r
                 originalToCopy.put(jobNode, nodeCopy);\r
@@ -246,7 +246,7 @@ public abstract class NodeFactory {
                 for (Node<?> child : jobNode.getChildren()) {\r
                     if (child instanceof SimpleNode<?>) {\r
                         originalToCopy.put(child, createImmutableSimpleNode(\r
-                                child.getNodeType(), null, child.getValue(), \r
+                                child.getNodeType(), null, child.getValue(),\r
                                 ((NodeModification) child).getModificationAction()));\r
                     } else if (child instanceof CompositeNode) {\r
                         jobQueue.push((CompositeNode) child);\r
@@ -254,8 +254,8 @@ public abstract class NodeFactory {
                 }\r
             }\r
         }\r
-       \r
+\r
         return (CompositeNode) originalToCopy.get(node);\r
     }\r
-    \r
+\r
 }\r