212f2bca925f0adb11c6a99ac87bcd6434fd261e
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CloseTransactionChain.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.datastore.messages;
10
11 import com.google.common.base.Preconditions;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15
16 public class CloseTransactionChain extends VersionedExternalizableMessage {
17     private static final long serialVersionUID = 1L;
18
19     private String transactionChainId;
20
21     public CloseTransactionChain() {
22     }
23
24     public CloseTransactionChain(final String transactionChainId, final short version) {
25         super(version);
26         this.transactionChainId = transactionChainId;
27     }
28
29     public String getTransactionChainId() {
30         return transactionChainId;
31     }
32
33     @Override
34     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
35         super.readExternal(in);
36         transactionChainId = in.readUTF();
37     }
38
39     @Override
40     public void writeExternal(ObjectOutput out) throws IOException {
41         super.writeExternal(out);
42         out.writeUTF(transactionChainId);
43     }
44
45     public static CloseTransactionChain fromSerializable(final Object serializable){
46         Preconditions.checkArgument(serializable instanceof CloseTransactionChain);
47         return (CloseTransactionChain)serializable;
48     }
49
50     public static boolean isSerializedType(Object message) {
51         return message instanceof CloseTransactionChain;
52     }
53 }