Make ReplicatedLogImplEntry final
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / ReplicatedLogImplEntry.java
index ceb5633d4d2deaedb8029a4eb9e7ee3864f68035..e5bf72233c197952daac0152f4eef53d01737c17 100644 (file)
@@ -8,41 +8,48 @@
 
 package org.opendaylight.controller.cluster.raft;
 
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-
+import com.google.common.base.Preconditions;
 import java.io.Serializable;
+import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 
-public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
-    Serializable {
-    private static final long serialVersionUID = 1L;
+/**
+ * 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;
 
-    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.payload = payload;
+        this.payload = Preconditions.checkNotNull(payload);
     }
 
-    @Override public Payload getData() {
+    @Override
+    public Payload getData() {
         return payload;
     }
 
-    @Override public long getTerm() {
+    @Override
+    public long getTerm() {
         return term;
     }
 
-    @Override public long getIndex() {
+    @Override
+    public long getIndex() {
         return index;
     }
 
-    @Override public String toString() {
-        return "Entry{" +
-            "index=" + index +
-            ", term=" + term +
-            '}';
+    @Override
+    public int size() {
+        return getData().size();
+    }
+
+    @Override
+    public String toString() {
+        return "Entry{index=" + index + ", term=" + term + '}';
     }
 }