Move byte-based serialization method
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / MergeModification.java
index 571443eedd3a89f2ce9d474cbfbd883919a8d7ff..465372736bb398769d811fd217319a1f1b694328 100644 (file)
@@ -8,22 +8,25 @@
 
 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.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+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;
 
 /**
- * MergeModification stores all the parameters required to merge data into the specified path
+ * MergeModification stores all the parameters required to merge data into the specified path.
  */
 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 +39,17 @@ 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) {
+        MergeModification mod = new MergeModification(version);
         mod.readExternal(in);
         return mod;
     }