Remove use of NodeIdentifierWithPredicates constructors 86/84186/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Sep 2019 06:24:33 +0000 (08:24 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Sep 2019 08:40:39 +0000 (10:40 +0200)
NodeIdentifierWithPredicates is becoming an abstract class, remove
references to its constructors.

Change-Id: I92f558978945867322d0e78229329e2fc7b0ca18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java

index aa908b2e09b6db280417c85be75988cb927e8f7e..cdfb21d986ee8a12d82c3f826358620595ba77c8 100644 (file)
@@ -37,7 +37,8 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -101,10 +102,9 @@ public final class NetconfTestUtils {
         Set<MapEntryNode> streamSet = new HashSet<>();
         for (String s : streamName) {
             MapEntryNode stream = Builders.mapEntryBuilder()
-                    .withNodeIdentifier(new YangInstanceIdentifier
-                            .NodeIdentifierWithPredicates(Stream.QNAME, nameNode, s))
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(Stream.QNAME, nameNode, s))
                     .withChild(Builders.leafBuilder()
-                            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(nameNode))
+                            .withNodeIdentifier(new NodeIdentifier(nameNode))
                             .withValue(s)
                             .build())
                     .build();
@@ -112,12 +112,12 @@ public final class NetconfTestUtils {
         }
 
         CollectionNodeBuilder<MapEntryNode, MapNode> streams =
-                Builders.mapBuilder().withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(Stream.QNAME));
+                Builders.mapBuilder().withNodeIdentifier(NodeIdentifier.create(Stream.QNAME));
         for (MapEntryNode mapEntryNode : streamSet) {
             streams.withChild(mapEntryNode);
         }
         return Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(Streams.QNAME))
+                .withNodeIdentifier(new NodeIdentifier(Streams.QNAME))
                 .withChild(streams.build())
                 .build();
     }
index 6fbfee531f58cf90c21b566fe611740121ea33a2..5908624515f80a1a0b66695fda555236c6e78c0f 100644 (file)
@@ -957,12 +957,8 @@ public final class ControllerContext implements SchemaContextListener, Closeable
             final ListSchemaNode node, final DOMMountPoint mount) {
         final QName nodeType = argument.getNodeType();
         final CharSequence nodeIdentifier = this.toRestconfIdentifier(nodeType, mount);
-        final Map<QName, Object> keyValues = argument.getKeyValues();
 
-        final StringBuilder builder = new StringBuilder();
-        builder.append('/');
-        builder.append(nodeIdentifier);
-        builder.append('/');
+        final StringBuilder builder = new StringBuilder().append('/').append(nodeIdentifier).append('/');
 
         final List<QName> keyDefinition = node.getKeyDefinition();
         boolean hasElements = false;
@@ -975,12 +971,14 @@ public final class ControllerContext implements SchemaContextListener, Closeable
                         builder.append('/');
                     }
 
+                    Preconditions.checkState(listChild instanceof LeafSchemaNode,
+                        "List key has to consist of leaves, not %s", listChild);
+
+                    final Object value = argument.getValue(key);
                     try {
-                        Preconditions.checkState(listChild instanceof LeafSchemaNode,
-                            "List key has to consist of leaves, not %s", listChild);
-                        builder.append(toUriString(keyValues.get(key), (LeafSchemaNode)listChild, mount));
+                        builder.append(toUriString(value, (LeafSchemaNode)listChild, mount));
                     } catch (final UnsupportedEncodingException e) {
-                        LOG.error("Error parsing URI: {}", keyValues.get(key), e);
+                        LOG.error("Error parsing URI: {}", value, e);
                         return null;
                     }
                     break;