Migrate deprecated yangtools method 10/82010/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 13 May 2019 07:26:34 +0000 (09:26 +0200)
committerStephen Kitt <skitt@redhat.com>
Tue, 14 May 2019 12:30:10 +0000 (12:30 +0000)
DataTreeCandidateNodes.fromNormalizedNode() has been deprecated
in favor of written() -- migrate this user.

Change-Id: I355058568c2c1512fbca083142b17a3a515e9329
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java

index bc1fca1..3b72692 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.controller.cluster.datastore.persisted;
 
 import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
@@ -55,25 +55,25 @@ public final class DataTreeCandidateInputOutput {
         if (children.isEmpty()) {
             LOG.debug("Modified node {} does not have any children, not instantiating it", identifier);
             return null;
-        } else {
-            return ModifiedDataTreeCandidateNode.create(identifier, type, children);
         }
+
+        return ModifiedDataTreeCandidateNode.create(identifier, type, children);
     }
 
     private static Collection<DataTreeCandidateNode> readChildren(final NormalizedNodeDataInput in) throws IOException {
         final int size = in.readInt();
-        if (size != 0) {
-            final Collection<DataTreeCandidateNode> ret = new ArrayList<>(size);
-            for (int i = 0; i < size; ++i) {
-                final DataTreeCandidateNode child = readNode(in);
-                if (child != null) {
-                    ret.add(child);
-                }
+        if (size == 0) {
+            return ImmutableList.of();
+        }
+
+        final Collection<DataTreeCandidateNode> ret = new ArrayList<>(size);
+        for (int i = 0; i < size; ++i) {
+            final DataTreeCandidateNode child = readNode(in);
+            if (child != null) {
+                ret.add(child);
             }
-            return ret;
-        } else {
-            return Collections.emptyList();
         }
+        return ret;
     }
 
     private static DataTreeCandidateNode readNode(final NormalizedNodeDataInput in) throws IOException {
@@ -90,7 +90,7 @@ public final class DataTreeCandidateInputOutput {
             case UNMODIFIED:
                 return null;
             case WRITE:
-                return DataTreeCandidateNodes.fromNormalizedNode(in.readNormalizedNode());
+                return DataTreeCandidateNodes.written(in.readNormalizedNode());
             default:
                 throw new IllegalArgumentException("Unhandled node type " + type);
         }
@@ -117,7 +117,7 @@ public final class DataTreeCandidateInputOutput {
                         readChildren(reader));
                 break;
             case WRITE:
-                rootNode = DataTreeCandidateNodes.fromNormalizedNode(reader.readNormalizedNode());
+                rootNode = DataTreeCandidateNodes.written(reader.readNormalizedNode());
                 break;
             case UNMODIFIED:
                 rootNode = AbstractDataTreeCandidateNode.createUnmodified();
@@ -172,7 +172,8 @@ public final class DataTreeCandidateInputOutput {
         }
     }
 
-    public static void writeDataTreeCandidate(final DataOutput out, DataTreeCandidate candidate) throws IOException {
+    public static void writeDataTreeCandidate(final DataOutput out, final DataTreeCandidate candidate)
+            throws IOException {
         try (NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
             writer.writeYangInstanceIdentifier(candidate.getRootPath());
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.