Fix warnings and clean up javadocs in sal-akka-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / base / messages / ApplySnapshot.java
1 /*
2  * Copyright (c) 2014 Cisco 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
9 package org.opendaylight.controller.cluster.raft.base.messages;
10
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.cluster.raft.Snapshot;
14
15 /**
16  * Internal message, issued by follower to its actor.
17  */
18 public class ApplySnapshot {
19     private static final Callback NOOP_CALLBACK = new Callback() {
20         @Override
21         public void onSuccess() {
22             // No-op
23         }
24
25         @Override
26         public void onFailure() {
27             // No-op
28         }
29     };
30
31     private final Snapshot snapshot;
32     private final Callback callback;
33
34     public ApplySnapshot(Snapshot snapshot) {
35         this(snapshot, NOOP_CALLBACK);
36     }
37
38     public ApplySnapshot(@Nonnull Snapshot snapshot, @Nonnull Callback callback) {
39         this.snapshot = Preconditions.checkNotNull(snapshot);
40         this.callback = Preconditions.checkNotNull(callback);
41     }
42
43     @Nonnull
44     public Snapshot getSnapshot() {
45         return snapshot;
46     }
47
48     @Nonnull
49     public Callback getCallback() {
50         return callback;
51     }
52
53     public interface Callback {
54         void onSuccess();
55
56         void onFailure();
57     }
58 }