Bump versions 9.0.4-SNAPSHOT
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadDataReply.java
index 8ac6e1b1494a68fd3e7f2f04e0081a4d7f538a10..2ed53ad0501a81e6ce9615fa318f4fa7a3fbb1c3 100644 (file)
@@ -5,96 +5,49 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.protobuf.ByteString;
-import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
-import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public class ReadDataReply implements VersionedSerializableMessage, Externalizable {
+@Deprecated(since = "9.0.0", forRemoval = true)
+public class ReadDataReply extends VersionedExternalizableMessage {
     private static final long serialVersionUID = 1L;
 
-    public static final Class<ReadDataReply> SERIALIZABLE_CLASS = ReadDataReply.class;
-
-    private NormalizedNode<?, ?> normalizedNode;
-    private short version;
+    private NormalizedNode normalizedNode;
 
     public ReadDataReply() {
     }
 
-    public ReadDataReply(NormalizedNode<?, ?> normalizedNode) {
+    public ReadDataReply(final NormalizedNode normalizedNode, final short version) {
+        super(version);
         this.normalizedNode = normalizedNode;
     }
 
-    public NormalizedNode<?, ?> getNormalizedNode() {
+    public NormalizedNode getNormalizedNode() {
         return normalizedNode;
     }
 
     @Override
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        version = in.readShort();
-        normalizedNode = SerializationUtils.deserializeNormalizedNode(in);
-    }
-
-    @Override
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeShort(version);
-        SerializationUtils.serializeNormalizedNode(normalizedNode, out);
+    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+        normalizedNode = SerializationUtils.readNormalizedNode(in).orElse(null);
     }
 
     @Override
-    public Object toSerializable(short toVersion) {
-        if(toVersion >= DataStoreVersions.LITHIUM_VERSION) {
-            version = toVersion;
-            return this;
-        } else {
-            return toSerializableReadDataReply(normalizedNode);
-        }
-    }
-
-    private static ShardTransactionMessages.ReadDataReply toSerializableReadDataReply(
-            NormalizedNode<?, ?> normalizedNode) {
-        if(normalizedNode != null) {
-            return ShardTransactionMessages.ReadDataReply.newBuilder()
-                    .setNormalizedNode(new NormalizedNodeToNodeCodec(null)
-                    .encode(normalizedNode).getNormalizedNode()).build();
-        } else {
-            return ShardTransactionMessages.ReadDataReply.newBuilder().build();
-
-        }
-    }
-
-    public static ReadDataReply fromSerializable(Object serializable) {
-        if(serializable instanceof ReadDataReply) {
-            return (ReadDataReply) serializable;
-        } else {
-            ShardTransactionMessages.ReadDataReply o =
-                    (ShardTransactionMessages.ReadDataReply) serializable;
-            return new ReadDataReply(new NormalizedNodeToNodeCodec(null).decode(o.getNormalizedNode()));
-        }
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+        SerializationUtils.writeNormalizedNode(out, getStreamVersion(), normalizedNode);
     }
 
-    public static ByteString fromSerializableAsByteString(Object serializable) {
-        if(serializable instanceof ReadDataReply) {
-            ReadDataReply r = (ReadDataReply)serializable;
-            return toSerializableReadDataReply(r.getNormalizedNode()).toByteString();
-        } else {
-            ShardTransactionMessages.ReadDataReply o =
-                    (ShardTransactionMessages.ReadDataReply) serializable;
-            return o.getNormalizedNode().toByteString();
-        }
+    public static ReadDataReply fromSerializable(final Object serializable) {
+        return (ReadDataReply) serializable;
     }
 
-    public static boolean isSerializedType(Object message) {
-        return SERIALIZABLE_CLASS.isAssignableFrom(message.getClass()) ||
-               message instanceof ShardTransactionMessages.ReadDataReply;
+    public static boolean isSerializedType(final Object message) {
+        return message instanceof ReadDataReply;
     }
 }