Add serialVersionUID fields
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / TransactionModification.java
index d71142201c2c25807e73fcd1e22128d16f5e7ca3..96bea87d46764c808d5a4cf50fd2dced686f66f6 100644 (file)
@@ -7,23 +7,22 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import com.google.common.annotations.Beta;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.io.IOException;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * An individual modification of a transaction's state. This class and its subclasses are not serializable, but rather
- * expose {@link #writeTo(NormalizedNodeDataOutput)} and {@link #readFrom(NormalizedNodeDataInput)} methods for explicit
- * serialization. The reason for this is that they are usually transmitted in bulk, hence it is advantageous to reuse
+ * expose {@link #writeTo(NormalizedNodeDataOutput)} and
+ * {@link #readFrom(NormalizedNodeDataInput, ReusableStreamReceiver)} methods for explicit serialization. The reason for
+ * this is that they are usually transmitted in bulk, hence it is advantageous to reuse
  * a {@link NormalizedNodeDataOutput} instance to achieve better compression.
- *
- * @author Robert Varga
  */
-@Beta
 public abstract class TransactionModification {
     static final byte TYPE_DELETE = 1;
     static final byte TYPE_MERGE = 2;
@@ -32,7 +31,7 @@ public abstract class TransactionModification {
     private final YangInstanceIdentifier path;
 
     TransactionModification(final YangInstanceIdentifier path) {
-        this.path = Preconditions.checkNotNull(path);
+        this.path = requireNonNull(path);
     }
 
     public final YangInstanceIdentifier getPath() {
@@ -51,17 +50,14 @@ public abstract class TransactionModification {
         out.writeYangInstanceIdentifier(path);
     }
 
-    static TransactionModification readFrom(final NormalizedNodeDataInput in) throws IOException {
+    static TransactionModification readFrom(final NormalizedNodeDataInput in, final ReusableStreamReceiver writer)
+            throws IOException {
         final byte type = in.readByte();
-        switch (type) {
-            case TYPE_DELETE:
-                return new TransactionDelete(in.readYangInstanceIdentifier());
-            case TYPE_MERGE:
-                return new TransactionMerge(in.readYangInstanceIdentifier(), in.readNormalizedNode());
-            case TYPE_WRITE:
-                return new TransactionWrite(in.readYangInstanceIdentifier(), in.readNormalizedNode());
-            default:
-                throw new IllegalArgumentException("Unhandled type " + type);
-        }
+        return switch (type) {
+            case TYPE_DELETE -> new TransactionDelete(in.readYangInstanceIdentifier());
+            case TYPE_MERGE -> new TransactionMerge(in.readYangInstanceIdentifier(), in.readNormalizedNode(writer));
+            case TYPE_WRITE -> new TransactionWrite(in.readYangInstanceIdentifier(), in.readNormalizedNode(writer));
+            default -> throw new IllegalArgumentException("Unhandled type " + type);
+        };
     }
 }