Make Payload Serializable
[controller.git] / opendaylight / md-sal / sal-akka-raft-example / src / main / java / org / opendaylight / controller / cluster / example / messages / KeyValue.java
index f76dc28486f889a07ec9ebb5b2da9331b92e49fa..93121834fef254cc7b8ad8dc64e3c1b00417eb09 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.example.messages;
 
-import java.io.Serializable;
 import org.opendaylight.controller.cluster.raft.messages.Payload;
 
-public class KeyValue extends Payload implements Serializable {
+public final class KeyValue extends Payload {
     private static final long serialVersionUID = 1L;
+
     private String key;
     private String value;
 
@@ -31,14 +31,6 @@ public class KeyValue extends Payload implements Serializable {
         return value;
     }
 
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
     @Override
     public String toString() {
         return "KeyValue{" + "key='" + key + '\'' + ", value='" + value + '\'' + '}';
@@ -48,4 +40,9 @@ public class KeyValue extends Payload implements Serializable {
     public int size() {
         return value.length() + key.length();
     }
+
+    @Override
+    protected Object writeReplace() {
+        return new KVv1(value, key);
+    }
 }