From b2d1f14b5562c644bcd7922591e466bcb29699af Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 4 Sep 2019 08:24:33 +0200 Subject: [PATCH] Remove use of NodeIdentifierWithPredicates constructors NodeIdentifierWithPredicates is becoming an abstract class, remove references to its constructors. Change-Id: I92f558978945867322d0e78229329e2fc7b0ca18 Signed-off-by: Robert Varga --- .../eventsources/netconf/NetconfTestUtils.java | 12 ++++++------ .../sal/restconf/impl/ControllerContext.java | 16 +++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java index aa908b2e09..cdfb21d986 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java @@ -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 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 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(); } diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java index 6fbfee531f..5908624515 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java @@ -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 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 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; -- 2.36.6