Separate lazy-versioned NormalizedNodeDataInput
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / NormalizedNodeInputOutput.java
index 5ad195a9b7cd207842a859ef6b78d139dc6f76f1..f46a9e2a5b13e6a312a6663f53157121b74bd730 100644 (file)
@@ -28,18 +28,7 @@ public final class NormalizedNodeInputOutput {
      * @throws IOException if an error occurs reading from the input
      */
     public static NormalizedNodeDataInput newDataInput(final @NonNull DataInput input) throws IOException {
-        final byte marker = input.readByte();
-        if (marker != TokenTypes.SIGNATURE_MARKER) {
-            throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker));
-        }
-
-        final short version = input.readShort();
-        switch (version) {
-            case TokenTypes.LITHIUM_VERSION:
-                return new NormalizedNodeInputStreamReader(input, true);
-            default:
-                throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version));
-        }
+        return new VersionedNormalizedNodeDataInput(input).delegate();
     }
 
     /**
@@ -50,7 +39,7 @@ public final class NormalizedNodeInputOutput {
      * @return a new {@link NormalizedNodeDataInput} instance
      */
     public static NormalizedNodeDataInput newDataInputWithoutValidation(final @NonNull DataInput input) {
-        return new NormalizedNodeInputStreamReader(input, false);
+        return new VersionedNormalizedNodeDataInput(input);
     }
 
     /**