Use YangInstanceIdentifier.EMPTY
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / AbstractThreePhaseCommitMessage.java
1 /*
2  * Copyright (c) 2016 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 java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14
15 /**
16  * Base class for a 3PC message.
17  *
18  * @author Thomas Pantelis
19  */
20 public abstract class AbstractThreePhaseCommitMessage extends VersionedExternalizableMessage {
21     private static final long serialVersionUID = 1L;
22
23     private String transactionID;
24
25     protected AbstractThreePhaseCommitMessage() {
26     }
27
28     protected AbstractThreePhaseCommitMessage(final String transactionID, final short version) {
29         super(version);
30         this.transactionID = Preconditions.checkNotNull(transactionID);
31     }
32
33     public String getTransactionID() {
34         return transactionID;
35     }
36
37     @Override
38     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
39         super.readExternal(in);
40         transactionID = in.readUTF();
41     }
42
43     @Override
44     public void writeExternal(ObjectOutput out) throws IOException {
45         super.writeExternal(out);
46         out.writeUTF(transactionID);
47     }
48
49     @Override
50     public String toString() {
51         return getClass().getSimpleName() + " [transactionID=" + transactionID + ", version=" + getVersion()
52                 + "]";
53     }
54 }