Bug 5019: Add QName param to NormalizedNodeWriter#leafSetEntryNode
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / stream / NormalizedNodeWriter.java
index b05b547dde49cc97084c777eef8dda8634885657..abb8c811c64c05096ff737a46e4efebaed2be224 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
@@ -135,10 +136,12 @@ public class NormalizedNodeWriter implements Closeable, Flushable {
     private boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException {
         if (node instanceof LeafSetEntryNode) {
             final LeafSetEntryNode<?> nodeAsLeafList = (LeafSetEntryNode<?>)node;
+            final QName name = nodeAsLeafList.getIdentifier().getNodeType();
             if(writer instanceof NormalizedNodeStreamAttributeWriter) {
-                ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(nodeAsLeafList.getValue(), nodeAsLeafList.getAttributes());
+                ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(name, nodeAsLeafList.getValue(),
+                        nodeAsLeafList.getAttributes());
             } else {
-                writer.leafSetEntryNode(nodeAsLeafList.getValue());
+                writer.leafSetEntryNode(name, nodeAsLeafList.getValue());
             }
             return true;
         } else if (node instanceof LeafNode) {
@@ -236,8 +239,12 @@ public class NormalizedNodeWriter implements Closeable, Flushable {
             writer.startMapNode(n.getIdentifier(), childSizeHint(n.getValue()));
             return writeChildren(n.getValue());
         }
+        if (node instanceof OrderedLeafSetNode) {
+            final LeafSetNode<?> n = (LeafSetNode<?>) node;
+            writer.startOrderedLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
+            return writeChildren(n.getValue());
+        }
         if (node instanceof LeafSetNode) {
-            //covers also OrderedLeafSetNode for which doesn't exist start* method
             final LeafSetNode<?> n = (LeafSetNode<?>) node;
             writer.startLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
             return writeChildren(n.getValue());