Add Magnesium stream version
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / NormalizedNodeInputOutput.java
index f46a9e2a5b13e6a312a6663f53157121b74bd730..7e2fb2906f01e5b29f7460b053957be49792317d 100644 (file)
@@ -43,12 +43,37 @@ public final class NormalizedNodeInputOutput {
     }
 
     /**
-     * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
+     * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output and latest current
+     * stream version.
      *
      * @param output the DataOutput to write to
      * @return a new {@link NormalizedNodeDataOutput} instance
      */
     public static NormalizedNodeDataOutput newDataOutput(final @NonNull DataOutput output) {
-        return new NormalizedNodeOutputStreamWriter(output);
+        return new NeonSR2NormalizedNodeOutputStreamWriter(output);
+    }
+
+    /**
+     * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
+     *
+     * @param output the DataOutput to write to
+     * @param version Streaming version to use
+     * @return a new {@link NormalizedNodeDataOutput} instance
+     */
+    public static NormalizedNodeDataOutput newDataOutput(final @NonNull DataOutput output,
+            final @NonNull NormalizedNodeStreamVersion version) {
+        switch (version) {
+            case LITHIUM:
+                return new LithiumNormalizedNodeOutputStreamWriter(output);
+            case NEON_SR2:
+                return new NeonSR2NormalizedNodeOutputStreamWriter(output);
+            case SODIUM_SR1:
+                return new SodiumSR1DataOutput(output);
+            case MAGNESIUM:
+                return new MagnesiumDataOutput(output);
+            default:
+                throw new IllegalStateException("Unhandled version " + version);
+        }
     }
+
 }