Guard against null transaction IDs
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ForwardedReadyTransaction.java
1 /*
2  * Copyright (c) 2014 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.datastore.messages;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.cluster.datastore.ReadWriteShardDataTreeTransaction;
12
13 /**
14  * Transaction ReadyTransaction message that is forwarded to the local Shard from the ShardTransaction.
15  *
16  * @author Thomas Pantelis
17  */
18 public class ForwardedReadyTransaction {
19     private final String transactionID;
20     private final ReadWriteShardDataTreeTransaction transaction;
21     private final boolean returnSerialized;
22     private final boolean doImmediateCommit;
23     private final short txnClientVersion;
24
25     public ForwardedReadyTransaction(String transactionID, short txnClientVersion,
26             ReadWriteShardDataTreeTransaction transaction, boolean returnSerialized,
27             boolean doImmediateCommit) {
28         this.transactionID = Preconditions.checkNotNull(transactionID);
29         this.transaction = Preconditions.checkNotNull(transaction);
30         this.returnSerialized = returnSerialized;
31         this.txnClientVersion = txnClientVersion;
32         this.doImmediateCommit = doImmediateCommit;
33     }
34
35     public String getTransactionID() {
36         return transactionID;
37     }
38
39     public ReadWriteShardDataTreeTransaction getTransaction() {
40         return transaction;
41     }
42
43     public boolean isReturnSerialized() {
44         return returnSerialized;
45     }
46
47     public short getTxnClientVersion() {
48         return txnClientVersion;
49     }
50
51     public boolean isDoImmediateCommit() {
52         return doImmediateCommit;
53     }
54 }