Avoid IllegalArgument on missing source
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / PrimaryNotFound.java
index c66e12cb395d4850392716644644d91dc830da4b..b47c91b6e5802ee7896ff30ba2b7d1035d8fc338 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.controller.cluster.datastore.messages;
 
 import com.google.common.base.Preconditions;
 
-public class PrimaryNotFound {
+public class PrimaryNotFound implements SerializableMessage {
+  public static final Class<PrimaryNotFound> SERIALIZABLE_CLASS = PrimaryNotFound.class;
 
     private final String shardName;
 
-    public PrimaryNotFound(String shardName){
+    public PrimaryNotFound(final String shardName){
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
 
@@ -22,13 +23,19 @@ public class PrimaryNotFound {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         PrimaryNotFound that = (PrimaryNotFound) o;
 
-        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) return false;
+        if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) {
+            return false;
+        }
 
         return true;
     }
@@ -37,4 +44,13 @@ public class PrimaryNotFound {
     public int hashCode() {
         return shardName != null ? shardName.hashCode() : 0;
     }
+
+  @Override
+  public Object toSerializable() {
+    return this;
+  }
+
+  public static PrimaryNotFound fromSerializable(final Object message){
+    return (PrimaryNotFound) message;
+  }
 }