*/
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.
*/
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 + "]";
}
}