Remove NormalizedNodeStreamReader
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / NormalizedNodeInputStreamReader.java
index 9f6d39aa194c370eeeefced90a999e87f4523814..3f6cbb743bc26568583b248a7276b87a11b3efa3 100644 (file)
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
  *
  */
 
-public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput, NormalizedNodeStreamReader {
+public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput {
 
     private static final Logger LOG = LoggerFactory.getLogger(NormalizedNodeInputStreamReader.class);
 
@@ -63,8 +63,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
     private NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier,
                                       Object, LeafNode<Object>> leafBuilder;
 
-    private NormalizedNodeAttrBuilder<NodeWithValue, Object,
-                                      LeafSetEntryNode<Object>> leafSetEntryBuilder;
+    private NormalizedNodeAttrBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> leafSetEntryBuilder;
 
     private final StringBuilder reusableStringBuilder = new StringBuilder(50);
 
@@ -75,8 +74,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
      */
     @Deprecated
     public NormalizedNodeInputStreamReader(final InputStream stream) throws IOException {
-        Preconditions.checkNotNull(stream);
-        input = new DataInputStream(stream);
+        this((DataInput) new DataInputStream(Preconditions.checkNotNull(stream)));
     }
 
     /**
@@ -84,7 +82,12 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
      */
     @Deprecated
     public NormalizedNodeInputStreamReader(final DataInput input) {
+        this(input, false);
+    }
+
+    NormalizedNodeInputStreamReader(final DataInput input, final boolean versionChecked) {
         this.input = Preconditions.checkNotNull(input);
+        readSignatureMarker = !versionChecked;
     }
 
     @Override
@@ -130,8 +133,13 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
                         withNodeIdentifier(augIdentifier)).build();
 
             case NodeTypes.LEAF_SET_ENTRY_NODE :
+                QName name = lastLeafSetQName;
+                if(name == null) {
+                    name = readQName();
+                }
+
                 Object value = readObject();
-                NodeWithValue leafIdentifier = new NodeWithValue(lastLeafSetQName, value);
+                NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(name, value);
 
                 LOG.debug("Reading leaf set entry node {}, value {}", leafIdentifier, value);
 
@@ -217,6 +225,13 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
                 return addLeafSetChildren(identifier.getNodeType(),
                         Builders.leafSetBuilder().withNodeIdentifier(identifier)).build();
 
+            case NodeTypes.ORDERED_LEAF_SET:
+                LOG.debug("Read ordered leaf set node {}", identifier);
+                ListNodeBuilder<Object, LeafSetEntryNode<Object>> orderedLeafSetBuilder =
+                        Builders.orderedLeafSetBuilder().withNodeIdentifier(identifier);
+                orderedLeafSetBuilder = addLeafSetChildren(identifier.getNodeType(), orderedLeafSetBuilder);
+                return orderedLeafSetBuilder.build();
+
             default :
                 return null;
         }
@@ -374,7 +389,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
                 return new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
 
             case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE :
-                return new NodeWithValue(readQName(), readObject());
+                return new NodeWithValue<>(readQName(), readObject());
 
             default :
                 return null;
@@ -413,19 +428,19 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput,
     }
 
     @Override
-    public void readFully(byte[] b) throws IOException {
+    public void readFully(final byte[] b) throws IOException {
         readSignatureMarkerAndVersionIfNeeded();
         input.readFully(b);
     }
 
     @Override
-    public void readFully(byte[] b, int off, int len) throws IOException {
+    public void readFully(final byte[] b, final int off, final int len) throws IOException {
         readSignatureMarkerAndVersionIfNeeded();
         input.readFully(b, off, len);
     }
 
     @Override
-    public int skipBytes(int n) throws IOException {
+    public int skipBytes(final int n) throws IOException {
         readSignatureMarkerAndVersionIfNeeded();
         return input.skipBytes(n);
     }