-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * 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.data.util;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\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.Node;\r
-import org.opendaylight.controller.yang.data.api.SimpleNode;\r
-\r
-public class Nodes {\r
-\r
- private Nodes() {\r
- }\r
-\r
- public static <T> SimpleNode<T> leafNode(QName name, T value) {\r
- return new SimpleNodeTO<T>(name, value, null);\r
- }\r
-\r
- public static CompositeNode containerNode(QName name, List<Node<?>> children) {\r
- return containerNode(name, children, null);\r
- }\r
-\r
- public static CompositeNode containerNode(QName name,\r
- List<Node<?>> children, CompositeNode parent) {\r
- return new ContainerNodeTO(name, parent, nodeMapFromList(children));\r
- }\r
-\r
- public static Map<QName, List<Node<?>>> nodeMapFromList(\r
- List<Node<?>> children) {\r
- Map<QName, List<Node<?>>> map = new HashMap<QName, List<Node<?>>>();\r
- for (Node<?> node : children) {\r
-\r
- QName name = node.getNodeType();\r
- List<Node<?>> targetList = map.get(name);\r
- if (targetList == null) {\r
- targetList = new ArrayList<Node<?>>();\r
- map.put(name, targetList);\r
- }\r
- targetList.add(node);\r
- }\r
- return map;\r
- }\r
-\r
- private static class ContainerNodeTO extends AbstractContainerNode {\r
-\r
- private final Map<QName, List<Node<?>>> nodeMap;\r
-\r
- public ContainerNodeTO(QName name, Map<QName, List<Node<?>>> nodeMap) {\r
- super(name);\r
- this.nodeMap = nodeMap;\r
- }\r
-\r
- public ContainerNodeTO(QName name, CompositeNode parent,\r
- Map<QName, List<Node<?>>> nodeMap) {\r
- super(name, parent);\r
- this.nodeMap = nodeMap;\r
- }\r
-\r
- @Override\r
- protected Map<QName, List<Node<?>>> getNodeMap() {\r
-\r
- return nodeMap;\r
- }\r
- }\r
-\r
- private static class SimpleNodeTO<T> extends AbstractNode<T> implements\r
- SimpleNode<T> {\r
-\r
- private final T value;\r
-\r
- protected SimpleNodeTO(QName name, T val, CompositeNode parent) {\r
- super(name, parent);\r
- value = val;\r
-\r
- }\r
-\r
- @Override\r
- public T getValue() {\r
- return value;\r
- }\r
-\r
- }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.yang.data.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.opendaylight.controller.yang.data.api.Node;
+import org.opendaylight.controller.yang.data.api.SimpleNode;
+
+public class Nodes {
+
+ private Nodes() {
+ }
+
+ public static <T> SimpleNode<T> leafNode(QName name, T value) {
+ return new SimpleNodeTO<T>(name, value, null);
+ }
+
+ public static CompositeNode containerNode(QName name, List<Node<?>> children) {
+ return containerNode(name, children, null);
+ }
+
+ public static CompositeNode containerNode(QName name,
+ List<Node<?>> children, CompositeNode parent) {
+ return new ContainerNodeTO(name, parent, nodeMapFromList(children));
+ }
+
+ public static Map<QName, List<Node<?>>> nodeMapFromList(
+ List<Node<?>> children) {
+ Map<QName, List<Node<?>>> map = new HashMap<QName, List<Node<?>>>();
+ for (Node<?> node : children) {
+
+ QName name = node.getNodeType();
+ List<Node<?>> targetList = map.get(name);
+ if (targetList == null) {
+ targetList = new ArrayList<Node<?>>();
+ map.put(name, targetList);
+ }
+ targetList.add(node);
+ }
+ return map;
+ }
+
+ private static class ContainerNodeTO extends AbstractContainerNode {
+
+ private final Map<QName, List<Node<?>>> nodeMap;
+
+ public ContainerNodeTO(QName name, Map<QName, List<Node<?>>> nodeMap) {
+ super(name);
+ this.nodeMap = nodeMap;
+ }
+
+ public ContainerNodeTO(QName name, CompositeNode parent,
+ Map<QName, List<Node<?>>> nodeMap) {
+ super(name, parent);
+ this.nodeMap = nodeMap;
+ }
+
+ @Override
+ protected Map<QName, List<Node<?>>> getNodeMap() {
+
+ return nodeMap;
+ }
+ }
+
+ private static class SimpleNodeTO<T> extends AbstractNode<T> implements
+ SimpleNode<T> {
+
+ private final T value;
+
+ protected SimpleNodeTO(QName name, T val, CompositeNode parent) {
+ super(name, parent);
+ value = val;
+
+ }
+
+ @Override
+ public T getValue() {
+ return value;
+ }
+
+ }
+
+}