Bug 7521: Convert byte[] to ShardManagerSnapshot in DatastoreSnapshot
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / SwitchShardBehavior.java
1 /*
2  * Copyright (c) 2015 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.datastore.shardmanager;
10
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
14 import org.opendaylight.controller.cluster.raft.RaftState;
15
16 final class SwitchShardBehavior {
17     private final ShardIdentifier shardId;
18     private final RaftState newState;
19     private final long term;
20
21     SwitchShardBehavior(final ShardIdentifier shardId, final RaftState newState, final long term) {
22         this.newState = Preconditions.checkNotNull(newState);
23         this.shardId = shardId;
24         this.term = term;
25     }
26
27     @Nullable ShardIdentifier getShardId() {
28         return shardId;
29     }
30
31     RaftState getNewState() {
32         return newState;
33     }
34
35     long getTerm() {
36         return term;
37     }
38
39     @Override
40     public String toString() {
41         final StringBuilder sb = new StringBuilder("SwitchShardBehavior{");
42         sb.append("shardId='").append(shardId).append('\'');
43         sb.append(", newState='").append(newState).append('\'');
44         sb.append(", term=").append(term);
45         sb.append('}');
46         return sb.toString();
47     }
48 }