Make ReplicatedLogImplEntry final 89/37489/1
authorRobert Varga <rovarga@cisco.com>
Tue, 12 Apr 2016 12:07:36 +0000 (14:07 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 12 Apr 2016 12:07:36 +0000 (14:07 +0200)
This is a simple DTO, make sure it cannot carry a null payload and
cannot be subclassed.

Change-Id: I6fbe1bfb18b6f1b127b357fc0f40d86cb26a81b7
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntry.java

index 799e75e..e5bf722 100644 (file)
@@ -8,21 +8,24 @@
 
 package org.opendaylight.controller.cluster.raft;
 
 
 package org.opendaylight.controller.cluster.raft;
 
+import com.google.common.base.Preconditions;
 import java.io.Serializable;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 
 import java.io.Serializable;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 
-public class ReplicatedLogImplEntry implements ReplicatedLogEntry, Serializable {
+/**
+ * A {@link ReplicatedLogEntry} implementation.
+ */
+public final class ReplicatedLogImplEntry implements ReplicatedLogEntry, Serializable {
     private static final long serialVersionUID = -9085798014576489130L;
 
     private final long index;
     private final long term;
     private final Payload payload;
 
     private static final long serialVersionUID = -9085798014576489130L;
 
     private final long index;
     private final long term;
     private final Payload payload;
 
-    public ReplicatedLogImplEntry(long index, long term, Payload payload) {
-
+    public ReplicatedLogImplEntry(final long index, final long term, final Payload payload) {
         this.index = index;
         this.term = term;
         this.index = index;
         this.term = term;
-        this.payload = payload;
+        this.payload = Preconditions.checkNotNull(payload);
     }
 
     @Override
     }
 
     @Override
@@ -47,9 +50,6 @@ public class ReplicatedLogImplEntry implements ReplicatedLogEntry, Serializable
 
     @Override
     public String toString() {
 
     @Override
     public String toString() {
-        return "Entry{" +
-            "index=" + index +
-            ", term=" + term +
-            '}';
+        return "Entry{index=" + index + ", term=" + term + '}';
     }
 }
     }
 }