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;
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;
}
*/
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);
}
/**
* 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());
}
/**
* 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);
}
/**
* 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]));
}
/**
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);
*/
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;