import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils.Applier;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormalizedNodeStreamWriter;
/**
* WriteModification stores all the parameters required to write data to the specified path.
}
@Override
- public void readExternal(final ObjectInput in) {
- SerializationUtils.deserializePathAndNode(in, this, APPLIER);
+ public void readExternal(final ObjectInput in) throws IOException {
+ SerializationUtils.readNodeAndPath(in, this, (instance, path, node) -> {
+ instance.setPath(path);
+ instance.data = node;
+ });
}
@Override
- public void writeExternal(final ObjectOutput out) {
- SerializationUtils.serializePathAndNode(getPath(), data, out);
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ SerializationUtils.writeNodeAndPath(out, getPath(), data);
}
- public static WriteModification fromStream(final NormalizedNodeDataInput in, final short version)
- throws IOException {
- final NormalizedNode<?, ?> node = in.readNormalizedNode();
+ public static WriteModification fromStream(final NormalizedNodeDataInput in, final short version,
+ final ReusableImmutableNormalizedNodeStreamWriter writer) throws IOException {
+ final NormalizedNode<?, ?> node = in.readNormalizedNode(writer);
final YangInstanceIdentifier path = in.readYangInstanceIdentifier();
return new WriteModification(version, path, node);
}
+ @Override
public void writeTo(final NormalizedNodeDataOutput out) throws IOException {
// FIXME: this should be inverted, as the path helps receivers in establishment of context
out.writeNormalizedNode(data);
out.writeYangInstanceIdentifier(getPath());
}
-
- private static final Applier<WriteModification> APPLIER = (instance, path, node) -> {
- instance.setPath(path);
- instance.data = node;
- };
}