Use SchemaPath->Absolute bridge methods 91/92991/3
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 8 Oct 2020 08:00:28 +0000 (10:00 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 16 Oct 2020 07:42:25 +0000 (07:42 +0000)
SchemaPath allows for easy transformation to ease migration, use
the methods as they improve readability.

Change-Id: I4b92ef9681e4bb722d2d9f4e6d4c5ac21d2368f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java

index ea4f4ba8b78359cf762fb2a3bff86d0ca4f881b3..33f49ebb64534102a757ea76864687994fb2acfc 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.messagebus.eventsources.netconf;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.time.Instant;
 import java.time.ZoneId;
@@ -45,7 +44,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 
 /**
  * Facade of mounted netconf device.
@@ -154,8 +152,7 @@ class NetconfEventSourceMount {
      */
     ListenerRegistration<DOMNotificationListener> registerNotificationListener(final DOMNotificationListener listener,
                                                                                final SchemaPath notificationPath) {
-        return notificationService.registerNotificationListener(listener,
-            Absolute.of(ImmutableList.copyOf(notificationPath.getPathFromRoot())));
+        return notificationService.registerNotificationListener(listener, notificationPath.asAbsolute());
     }
 
 }
index 5087f93b79ec880d960e3a69219112bb58f45ea6..46f206f6d9725e5b096260d3bf954b8add18ef9d 100644 (file)
@@ -15,7 +15,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
@@ -120,8 +119,7 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
         this.contextTree = DataSchemaContextTree.from(schemaContext);
 
         this.mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), SchemaNode::getQName);
-        this.actions = Maps.uniqueIndex(getActions(schemaContext),
-            action -> Absolute.of(ImmutableList.copyOf(action.getPath().getPathFromRoot())));
+        this.actions = Maps.uniqueIndex(getActions(schemaContext), action -> action.getPath().asAbsolute());
 
         // RFC6020 normal notifications
         this.mappedNotifications = Multimaps.index(schemaContext.getNotifications(),
@@ -206,7 +204,7 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
         if (nestedNotificationInfo != null) {
             return new NetconfDeviceTreeNotification(content,
                 // FIXME: improve this to cache the path
-                Absolute.of(ImmutableList.copyOf(mostRecentNotification.getPath().getPathFromRoot())),
+                mostRecentNotification.getPath().asAbsolute(),
                 stripped.getKey(), nestedNotificationInfo.domDataTreeIdentifier);
         }
 
index 4366d5cdbafa922444925566cd8573ef56a067d8..1a57aeeffd1bd8493a29fe68002e7bb9fda46d2c 100644 (file)
@@ -28,7 +28,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
 import static org.opendaylight.netconf.util.NetconfUtil.NETCONF_DATA_QNAME;
 
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import java.io.IOException;
@@ -502,7 +501,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest {
         List<ActionDefinition> actions = NetconfMessageTransformer.getActions(ACTION_SCHEMA);
         assertEquals(schemaPaths.size(), actions.size());
         for (ActionDefinition actionDefinition : actions) {
-            Absolute path = Absolute.of(ImmutableList.copyOf(actionDefinition.getPath().getPathFromRoot()));
+            Absolute path = actionDefinition.getPath().asAbsolute();
             assertTrue(schemaPaths.remove(path));
         }
     }