Merge "Startup arch - add odlparent to root pom."
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / VersionedExternalizableMessage.java
1 /*
2  * Copyright (c) 2015 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 java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14
15 /**
16  * Abstract base class for a versioned Externalizable message.
17  *
18  * @author Thomas Pantelis
19  */
20 public abstract class VersionedExternalizableMessage implements Externalizable, SerializableMessage {
21     private static final long serialVersionUID = 1L;
22
23     private short version;
24
25     public VersionedExternalizableMessage() {
26     }
27
28     public VersionedExternalizableMessage(short version) {
29         this.version = version;
30     }
31
32     public short getVersion() {
33         return version;
34     }
35
36     @Override
37     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
38         version = in.readShort();
39     }
40
41     @Override
42     public void writeExternal(ObjectOutput out) throws IOException {
43         out.writeShort(version);
44     }
45 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.