Refactor anydata-related interfaces
[yangtools.git] / yang / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / LeafListEntryNodeDataWithSchema.java
index 8373dc7e528caeae52455c150936e314fc1e6aaa..df0e9d7962304e8e1440f4dc3b9ab4bd1dac0ab3 100644 (file)
@@ -8,9 +8,10 @@
 package org.opendaylight.yangtools.yang.data.util;
 
 import java.io.IOException;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamAttributeWriter;
+import org.opendaylight.yangtools.rfc7952.data.api.NormalizedMetadataStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 
 /**
  * Utility class used for tracking parser state as needed by a StAX-like parser.
@@ -19,20 +20,19 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
  * <p>
  * Represents a YANG leaf-list entry node.
  */
-public class LeafListEntryNodeDataWithSchema extends SimpleNodeDataWithSchema {
-    public LeafListEntryNodeDataWithSchema(final DataSchemaNode dataSchemaNode) {
+public class LeafListEntryNodeDataWithSchema extends SimpleNodeDataWithSchema<LeafListSchemaNode> {
+    public LeafListEntryNodeDataWithSchema(final LeafListSchemaNode dataSchemaNode) {
         super(dataSchemaNode);
     }
 
     @Override
-    public void write(final NormalizedNodeStreamWriter writer) throws IOException {
+    public void write(final NormalizedNodeStreamWriter writer, final NormalizedMetadataStreamWriter metaWriter)
+            throws IOException {
         writer.nextDataSchemaNode(getSchema());
 
-        if (writer instanceof NormalizedNodeStreamAttributeWriter && getAttributes() != null) {
-            ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(getSchema().getQName(), getValue(),
-                    getAttributes());
-        } else {
-            writer.leafSetEntryNode(getSchema().getQName(), getValue());
-        }
+        writer.startLeafSetEntryNode(new NodeWithValue<>(getSchema().getQName(), getValue()));
+        writeMetadata(metaWriter);
+        writer.scalarValue(getValue());
+        writer.endNode();
     }
 }