Deprecate old RaftVersions
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / client / messages / GetSnapshotReply.java
index f3521deb3b2b8ef89bf70ef3e4ea2e63a77ac8a0..36c534654cabb80469c5035522805c351f354f37 100644 (file)
@@ -7,8 +7,11 @@
  */
 package org.opendaylight.controller.cluster.raft.client.messages;
 
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
+import static java.util.Objects.requireNonNull;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
 
 /**
  * Reply to GetSnapshot that returns a serialized Snapshot instance.
@@ -17,25 +20,26 @@ import javax.annotation.Nonnull;
  */
 public class GetSnapshotReply {
     private final String id;
-    private final byte[] snapshot;
+    private final Snapshot snapshot;
 
-    public GetSnapshotReply(@Nonnull String id, @Nonnull byte[] snapshot) {
-        this.id = Preconditions.checkNotNull(id);
-        this.snapshot = Preconditions.checkNotNull(snapshot);
+    public GetSnapshotReply(@NonNull String id, @NonNull Snapshot snapshot) {
+        this.id = requireNonNull(id);
+        this.snapshot = requireNonNull(snapshot);
     }
 
-    @Nonnull
-    public String getId() {
+    public @NonNull String getId() {
         return id;
     }
 
-    @Nonnull
-    public byte[] getSnapshot() {
+    @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+            + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+            + "Also it would be inefficient to create a return copy as the byte[] could be large.")
+    public @NonNull Snapshot getSnapshot() {
         return snapshot;
     }
 
     @Override
     public String toString() {
-        return "GetSnapshotReply [id=" + id + ", snapshot.length=" + snapshot.length + "]";
+        return "GetSnapshotReply [id=" + id + ", snapshot=" + snapshot + "]";
     }
 }