- public static void serializePath(YangInstanceIdentifier path, DataOutput out) {
- Preconditions.checkNotNull(path);
- try {
- NormalizedNodeDataOutput streamWriter = streamWriter(out);
- streamWriter.writeYangInstanceIdentifier(path);
- } catch (IOException e) {
- throw new IllegalArgumentException(String.format("Error serializing path %s", path), e);
+ public static void writePath(final DataOutput out, final @NonNull YangInstanceIdentifier path)
+ throws IOException {
+ try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+ stream.writeYangInstanceIdentifier(path);
+ }
+ }
+
+ public static void writeNodeAndPath(final DataOutput out, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> node) throws IOException {
+ try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+ stream.writeNormalizedNode(node);
+ stream.writeYangInstanceIdentifier(path);
+ }
+ }
+
+ public static void writePathAndNode(final DataOutput out, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> node) throws IOException {
+ try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+ stream.writeYangInstanceIdentifier(path);
+ stream.writeNormalizedNode(node);