import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
*/
@Beta
public interface NormalizedNodeDataInput extends DataInput {
+ /**
+ * Interpret current stream position as a NormalizedNode, stream its events into a NormalizedNodeStreamWriter.
+ *
+ * @param writer Writer to emit events to
+ * @throws IOException if an error occurs
+ * @throws IllegalStateException if the dictionary has been detached
+ * @throws NullPointerException if {@code writer} is null
+ */
+ void streamNormalizedNode(NormalizedNodeStreamWriter writer) throws IOException;
+
/**
* Read a normalized node from the reader.
*
* @throws IOException if an error occurs
* @throws IllegalStateException if the dictionary has been detached
*/
- NormalizedNode<?, ?> readNormalizedNode() throws IOException;
+ default NormalizedNode<?, ?> readNormalizedNode() throws IOException {
+ final NormalizedNodeResult result = new NormalizedNodeResult();
+ try (NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(result)) {
+ streamNormalizedNode(writer);
+ }
+ return result.getResult();
+ }
YangInstanceIdentifier readYangInstanceIdentifier() throws IOException;