Bug 5019: Add QName param to NormalizedNodeWriter#leafSetEntryNode
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / ListNodeDataWithSchema.java
index d21cd9a77a01000a9e48cb3b941899e68dc7d06f..abbf1eaec48dd67cf90c4a6e455e8c1271e4cab2 100644 (file)
@@ -8,8 +8,7 @@
 package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import java.io.IOException;
-
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.SchemaAwareNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
@@ -20,9 +19,13 @@ class ListNodeDataWithSchema extends CompositeNodeDataWithSchema {
     }
 
     @Override
-    public void write(final NormalizedNodeStreamWriter writer) throws IOException {
-        if (((ListSchemaNode) getSchema()).getKeyDefinition().isEmpty()) {
+    public void write(final SchemaAwareNormalizedNodeStreamWriter writer) throws IOException {
+        final ListSchemaNode schema = (ListSchemaNode) getSchema();
+        writer.nextDataSchemaNode(schema);
+        if (schema.getKeyDefinition().isEmpty()) {
             writer.startUnkeyedList(provideNodeIdentifier(), childSizeHint());
+        } else if(schema.isUserOrdered()) {
+            writer.startOrderedMapNode(provideNodeIdentifier(), childSizeHint());
         } else {
             writer.startMapNode(provideNodeIdentifier(), childSizeHint());
         }