BUG-5280: Remove PeristentMessages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / MergeModification.java
index 571443eedd3a89f2ce9d474cbfbd883919a8d7ff..10b9b94242a07d11e767c902a28957055ee932a5 100644 (file)
@@ -10,12 +10,11 @@ package org.opendaylight.controller.cluster.datastore.modification;
 
 import java.io.IOException;
 import java.io.ObjectInput;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
-import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.sal.core.spi.data.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;
 
 /**
  * MergeModification stores all the parameters required to merge data into the specified path
@@ -24,6 +23,11 @@ public class MergeModification extends WriteModification {
     private static final long serialVersionUID = 1L;
 
     public MergeModification() {
+        this(DataStoreVersions.CURRENT_VERSION);
+    }
+
+    public MergeModification(short version) {
+        super(version);
     }
 
     public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
@@ -36,19 +40,18 @@ public class MergeModification extends WriteModification {
     }
 
     @Override
-    public byte getType() {
-        return MERGE;
+    public void apply(final DataTreeModification transaction) {
+        transaction.merge(getPath(), getData());
     }
 
-    @Deprecated
-    public static MergeModification fromSerializable(final Object serializable) {
-        PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
-        Decoded decoded = new NormalizedNodeToNodeCodec(null).decode(o.getPath(), o.getData());
-        return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode());
+    @Override
+    public byte getType() {
+        return MERGE;
     }
 
-    public static MergeModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException {
-        MergeModification mod = new MergeModification();
+    public static MergeModification fromStream(ObjectInput in, short version)
+            throws ClassNotFoundException, IOException {
+        MergeModification mod = new MergeModification(version);
         mod.readExternal(in);
         return mod;
     }