ReadData and ReadDataReply protobuff messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadData.java
index 2f56a9740b2d4872a116dbccc31ceeb33e6425f1..cb6347f3e54909330ea924956029f895f44f69e1 100644 (file)
@@ -8,9 +8,12 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
+import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 public class ReadData {
+  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadData.class;
   private final InstanceIdentifier path;
 
   public ReadData(InstanceIdentifier path) {
@@ -20,4 +23,15 @@ public class ReadData {
   public InstanceIdentifier getPath() {
     return path;
   }
+
+  public Object toSerializable(){
+    return ShardTransactionMessages.ReadData.newBuilder()
+        .setInstanceIdentifierPathArguments(path.toString())
+        .build();
+  }
+
+  public static ReadData fromSerializable(Object serializable){
+    ShardTransactionMessages.ReadData o = (ShardTransactionMessages.ReadData) serializable;
+    return new ReadData(InstanceIdentifierUtils.from(o.getInstanceIdentifierPathArguments()));
+  }
 }