b0c36ace2b4174ae5f675a2c7200e7df2b435943
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / client / messages / GetSnapshotReply.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.raft.client.messages;
9
10 import com.google.common.base.Preconditions;
11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
14
15 /**
16  * Reply to GetSnapshot that returns a serialized Snapshot instance.
17  *
18  * @author Thomas Pantelis
19  */
20 public class GetSnapshotReply {
21     private final String id;
22     private final Snapshot snapshot;
23
24     public GetSnapshotReply(@Nonnull String id, @Nonnull Snapshot snapshot) {
25         this.id = Preconditions.checkNotNull(id);
26         this.snapshot = Preconditions.checkNotNull(snapshot);
27     }
28
29     @Nonnull
30     public String getId() {
31         return id;
32     }
33
34     @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
35             + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
36             + "Also it would be inefficient to create a return copy as the byte[] could be large.")
37     @Nonnull
38     public Snapshot getSnapshot() {
39         return snapshot;
40     }
41
42     @Override
43     public String toString() {
44         return "GetSnapshotReply [id=" + id + ", snapshot=" + snapshot + "]";
45     }
46 }