Refactor VersionedExternalizableMessage messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadyTransactionReply.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 java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
15
16 public class ReadyTransactionReply extends VersionedExternalizableMessage {
17     private static final long serialVersionUID = 1L;
18
19     private String cohortPath;
20
21     public ReadyTransactionReply() {
22     }
23
24     public ReadyTransactionReply(String cohortPath) {
25         this(cohortPath, DataStoreVersions.CURRENT_VERSION);
26     }
27
28     public ReadyTransactionReply(String cohortPath, short version) {
29         super(version);
30         this.cohortPath = cohortPath;
31     }
32
33     public String getCohortPath() {
34         return cohortPath;
35     }
36
37     @Override
38     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
39         super.readExternal(in);
40         cohortPath = in.readUTF();
41     }
42
43     @Override
44     public void writeExternal(ObjectOutput out) throws IOException {
45         super.writeExternal(out);
46         out.writeUTF(cohortPath);
47     }
48
49     @Override
50     protected Object newLegacySerializedInstance() {
51         // no legacy serialized type for this class; return self
52         return this;
53     }
54
55     public static ReadyTransactionReply fromSerializable(Object serializable) {
56         return (ReadyTransactionReply)serializable;
57     }
58
59     public static boolean isSerializedType(Object message) {
60         return message instanceof ReadyTransactionReply;
61     }
62 }