Clean up adapter constructors 23/108823/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Nov 2023 17:14:02 +0000 (18:14 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Nov 2023 20:58:41 +0000 (21:58 +0100)
Reorder arguments to match what we are passing to superclasses. We will
use this as a springboard to further shuffling around.

JIRA: NETCONF-1102
Change-Id: I403bf59915818339455484b574ea0f204bad4c87
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/AbstractCommonSubscriber.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/DeviceNotificationListenerAdaptor.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/ListenerAdapter.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/ListenersBroker.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/NotificationListenerAdapter.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/ListenerAdapterTest.java

index ffcf8f58545f22b277c65bce54fae4cd1cf8be63..3f681574e9b58995c067317d9acefe9d3ccfc727 100644 (file)
@@ -53,7 +53,7 @@ abstract class AbstractCommonSubscriber<T> extends AbstractNotificationsData imp
     private final EventFormatterFactory<T> formatterFactory;
     private final NotificationOutputType outputType;
     private final String streamName;
-    private final ListenersBroker listenersBroker;
+    protected final @NonNull ListenersBroker listenersBroker;
 
     @GuardedBy("this")
     private final Set<StreamSessionHandler> subscribers = new HashSet<>();
index 4b5e0b5b48dadfe5b89422c34a1508a1ca48c44c..639997d404edc1c5fb5bed2e911bbff0b401c077 100644 (file)
@@ -32,18 +32,16 @@ public final class DeviceNotificationListenerAdaptor extends AbstractNotificatio
     private final @NonNull EffectiveModelContext effectiveModel;
     private final @NonNull DOMMountPointService mountPointService;
     private final @NonNull YangInstanceIdentifier instanceIdentifier;
-    private final @NonNull ListenersBroker listenersBroker;
 
     private ListenerRegistration<DOMMountPointListener> reg;
 
-    public DeviceNotificationListenerAdaptor(final String streamName, final NotificationOutputType outputType,
-            final EffectiveModelContext effectiveModel, final DOMMountPointService mountPointService,
-            final YangInstanceIdentifier path, final ListenersBroker listenersBroker) {
+    DeviceNotificationListenerAdaptor(final String streamName, final NotificationOutputType outputType,
+            final ListenersBroker listenersBroker, final EffectiveModelContext effectiveModel,
+            final DOMMountPointService mountPointService, final YangInstanceIdentifier instanceIdentifier) {
         super(streamName, outputType, listenersBroker);
         this.effectiveModel = requireNonNull(effectiveModel);
         this.mountPointService = requireNonNull(mountPointService);
-        instanceIdentifier = requireNonNull(path);
-        this.listenersBroker = requireNonNull(listenersBroker);
+        this.instanceIdentifier = requireNonNull(instanceIdentifier);
     }
 
     public synchronized void listen(final DOMNotificationService notificationService, final Set<Absolute> paths) {
index 7d3460d45a9e79015e6fdb64551c5ec0c0c74527..e0177c7958ceed28653b72abfc7899f208ef6dbe 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.restconf.nb.rfc8040.streams;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import java.time.Instant;
 import java.util.Collection;
@@ -48,9 +47,9 @@ public class ListenerAdapter extends AbstractCommonSubscriber<Collection<DataTre
      * @param streamName The name of the stream.
      * @param outputType Type of output on notification (JSON, XML).
      */
-    @VisibleForTesting
-    public ListenerAdapter(final LogicalDatastoreType datastore, final YangInstanceIdentifier path,
-            final String streamName, final NotificationOutputType outputType, final ListenersBroker listenersBroker) {
+    ListenerAdapter(final String streamName, final NotificationOutputType outputType,
+            final ListenersBroker listenersBroker, final LogicalDatastoreType datastore,
+            final YangInstanceIdentifier path) {
         super(streamName, outputType, getFormatterFactory(outputType), listenersBroker);
         this.datastore = requireNonNull(datastore);
         this.path = requireNonNull(path);
index 2e3dc1b379d984c42ff2615008690c2cf44d49e9..5a2e5d277e4b6ca7b189b3b9ab04d824553c0078 100644 (file)
@@ -194,7 +194,7 @@ public abstract sealed class ListenersBroker {
         final long stamp = dataChangeListenersLock.writeLock();
         try {
             return dataChangeListeners.computeIfAbsent(sb.toString(),
-                streamName -> new ListenerAdapter(datastore, path, streamName, outputType, this));
+                streamName -> new ListenerAdapter(streamName, outputType, this, datastore, path));
         } finally {
             dataChangeListenersLock.unlockWrite(stamp);
         }
@@ -239,7 +239,7 @@ public abstract sealed class ListenersBroker {
         final long stamp = notificationListenersLock.writeLock();
         try {
             return notificationListeners.computeIfAbsent(sb.toString(),
-                streamName -> new NotificationListenerAdapter(notifications, streamName, outputType, this));
+                streamName -> new NotificationListenerAdapter(streamName, outputType, this, notifications));
         } finally {
             notificationListenersLock.unlockWrite(stamp);
         }
@@ -264,8 +264,8 @@ public abstract sealed class ListenersBroker {
         final long stamp = deviceNotificationListenersLock.writeLock();
         try {
             return deviceNotificationListeners.computeIfAbsent(sb.toString(),
-                streamName -> new DeviceNotificationListenerAdaptor(streamName, outputType, refSchemaCtx,
-                    mountPointService, path, this));
+                streamName -> new DeviceNotificationListenerAdaptor(streamName, outputType, this, refSchemaCtx,
+                    mountPointService, path));
         } finally {
             deviceNotificationListenersLock.unlockWrite(stamp);
         }
index fb8bc320e25cabf6d6b21c89fb5d90d62b33a590..b27ab756689aec56e8148d429a2fdc9c3aa56bb7 100644 (file)
@@ -31,8 +31,8 @@ public final class NotificationListenerAdapter extends AbstractNotificationListe
      * @param outputType Type of output on notification (JSON or XML).
      * @param listenersBroker Associated {@link ListenersBroker}
      */
-    NotificationListenerAdapter(final ImmutableSet<QName> paths, final String streamName,
-            final NotificationOutputType outputType, final ListenersBroker listenersBroker) {
+    NotificationListenerAdapter(final String streamName, final NotificationOutputType outputType,
+            final ListenersBroker listenersBroker, final ImmutableSet<QName> paths) {
         super(streamName, outputType, listenersBroker);
         this.paths = requireNonNull(paths);
     }
index cc927d02b69a5aa104b72e38cb07dafb4ac4370c..693eb90411003486eb92ec7a0cce2ff2c2d24ac3 100644 (file)
@@ -180,7 +180,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
                 final NotificationOutputType outputType, final boolean leafNodesOnly,
                 final boolean skipNotificationData, final boolean changedLeafNodesOnly, final boolean childNodesOnly,
                 final ListenersBroker listenersBroker) {
-            super(LogicalDatastoreType.CONFIGURATION, path, streamName, outputType, listenersBroker);
+            super(streamName, outputType, listenersBroker, LogicalDatastoreType.CONFIGURATION, path);
             setQueryParams(NotificationQueryParams.of(StartTimeParam.forUriValue("1970-01-01T00:00:00Z"), null, null,
                 leafNodesOnly ? LeafNodesOnlyParam.of(true) : null,
                 skipNotificationData ? SkipNotificationDataParam.of(true) : null,