Merge changes I0eabfe3d,I58faf7df,I7e7758f4,Ic56afe1b,I623aa497
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / NodeFactory.java
index 735ff27c44957cfd154fc49a30c421fcd5d8e7e2..ee1dda9bdeda3f31b451aa0051d80ffa98e33120 100644 (file)
@@ -8,12 +8,13 @@
 package org.opendaylight.yangtools.yang.data.impl;
 
 import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Deque;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Stack;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
@@ -23,11 +24,14 @@ import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.NodeModification;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 
 /**
  * @author michal.rehak
  *
+ * @deprecated Use {@link Builders} instead.
  */
+@Deprecated
 public abstract class NodeFactory {
 
     /**
@@ -52,8 +56,7 @@ public abstract class NodeFactory {
     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);
+        MutableSimpleNodeTOImpl<T> simpleNodeTOImpl = new MutableSimpleNodeTOImpl<>(qName, parent, (T) value, modifyAction);
         simpleNodeTOImpl.setOriginal(original);
         return simpleNodeTOImpl;
     }
@@ -113,9 +116,7 @@ public abstract class NodeFactory {
      */
     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;
+        return new CompositeNodeTOImpl(qName, parent, value, modifyAction);
     }
 
     /**
@@ -124,9 +125,7 @@ public abstract class NodeFactory {
      * has no reference to this copy
      */
     public static <T> SimpleNode<T> copyNode(final SimpleNode<T> node) {
-        SimpleNode<T> twinNode = createImmutableSimpleNode(
-                    node.getNodeType(), node.getParent(), node.getValue());
-        return twinNode;
+        return createImmutableSimpleNode(node.getNodeType(), node.getParent(), node.getValue());
     }
 
     /**
@@ -135,10 +134,9 @@ public abstract class NodeFactory {
      * has no reference to this copy
      */
     public static <T> MutableSimpleNode<T> copyNodeAsMutable(final SimpleNode<T> node) {
-        MutableSimpleNode<T> twinNode = createMutableSimpleNode(
-                    node.getNodeType(), node.getParent(), node.getValue(),
-                    node.getModificationAction(), null);
-        return twinNode;
+        return createMutableSimpleNode(
+                node.getNodeType(), node.getParent(), node.getValue(),
+                node.getModificationAction(), null);
     }
 
     /**
@@ -159,7 +157,7 @@ public abstract class NodeFactory {
      * have no reference to this copy
      */
     public static CompositeNode copyNode(final CompositeNode node) {
-       return copyNode(node, node.getValue().toArray(new Node<?>[0]));
+        return copyNode(node, node.getValue().toArray(new Node<?>[0]));
     }
 
     /**
@@ -178,7 +176,7 @@ public abstract class NodeFactory {
 
         MutableCompositeNode mutableRoot = createMutableCompositeNode(node.getNodeType(), null, null,
                 node.getModificationAction(), null);
-        Stack<SimpleEntry<CompositeNode, MutableCompositeNode>> jobQueue = new Stack<>();
+        final Deque<SimpleEntry<CompositeNode, MutableCompositeNode>> jobQueue = new ArrayDeque<>();
         jobQueue.push(new SimpleEntry<CompositeNode, MutableCompositeNode>(node, mutableRoot));
         originalToCopy.put(node, mutableRoot);
 
@@ -224,7 +222,7 @@ public abstract class NodeFactory {
      */
     public static CompositeNode copyDeepAsImmutable(final CompositeNode node,
             final Map<Node<?>, Node<?>> originalToCopyArg) {
-        Stack<CompositeNode> jobQueue = new Stack<>();
+        final Deque<CompositeNode> jobQueue = new ArrayDeque<>();
         jobQueue.push(node);
 
         Map<Node<?>, Node<?>> originalToCopy = originalToCopyArg;