Bug 7521: Move DatastoreSnapshotList et al to persisted package
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / VersionedExternalizableMessage.java
index 17b93f4b04d5f6d7445f6b2f1d262b7d41162d0d..781580a643ec3e03a98e26327fb2a5374b41d319 100644 (file)
@@ -27,7 +27,7 @@ public abstract class VersionedExternalizableMessage implements Externalizable,
     }
 
     public VersionedExternalizableMessage(short version) {
-        this.version = version <= DataStoreVersions.CURRENT_VERSION ? version: DataStoreVersions.CURRENT_VERSION;
+        this.version = version <= DataStoreVersions.CURRENT_VERSION ? version : DataStoreVersions.CURRENT_VERSION;
     }
 
     public short getVersion() {
@@ -43,4 +43,19 @@ public abstract class VersionedExternalizableMessage implements Externalizable,
     public void writeExternal(ObjectOutput out) throws IOException {
         out.writeShort(version);
     }
+
+    @Override
+    public final Object toSerializable() {
+        if (getVersion() < DataStoreVersions.BORON_VERSION) {
+            throw new UnsupportedOperationException("Versions prior to " + DataStoreVersions.BORON_VERSION
+                    + " are not supported");
+        }
+
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + " [version=" + getVersion() + "]";
+    }
 }