Take advantage of AugmentationIdentifier.create()
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / LithiumNormalizedNodeInputStreamReader.java
index 3b4f2dad05d1170a9cc96fef48b096693e2e5dea..84e96bfb917f90ade240fd3a5671f38edafd5b78 100755 (executable)
@@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.Sets;
 import java.io.DataInput;
 import java.io.IOException;
 import java.io.StringReader;
@@ -240,8 +241,8 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
 
     private Set<QName> readQNameSet() throws IOException {
         // Read the children count
-        int count = input.readInt();
-        Set<QName> children = new HashSet<>(count);
+        final int count = input.readInt();
+        final Set<QName> children = Sets.newHashSetWithExpectedSize(count);
         for (int i = 0; i < count; i++) {
             children.add(readQName());
         }
@@ -249,7 +250,7 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
     }
 
     AugmentationIdentifier readAugmentationIdentifier() throws IOException {
-        return new AugmentationIdentifier(readQNameSet());
+        return AugmentationIdentifier.create(readQNameSet());
     }
 
     NodeIdentifier readNodeIdentifier() throws IOException {
@@ -261,9 +262,9 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
         final int count = input.readInt();
         switch (count) {
             case 0:
-                return new NodeIdentifierWithPredicates(qname);
+                return NodeIdentifierWithPredicates.of(qname);
             case 1:
-                return new NodeIdentifierWithPredicates(qname, readQName(), readObject());
+                return NodeIdentifierWithPredicates.of(qname, readQName(), readObject());
             default:
                 // ImmutableList is used by ImmutableOffsetMapTemplate for lookups, hence we use that.
                 final Builder<QName> keys = ImmutableList.builderWithExpectedSize(count);
@@ -273,7 +274,7 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
                     values[i] = readObject();
                 }
 
-                return new NodeIdentifierWithPredicates(qname, ImmutableOffsetMapTemplate.ordered(keys.build())
+                return NodeIdentifierWithPredicates.of(qname, ImmutableOffsetMapTemplate.ordered(keys.build())
                     .instantiateWithValues(values));
         }
     }