Fix Notification raw types 37/98637/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 22 Nov 2021 13:39:34 +0000 (14:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 22 Nov 2021 13:40:40 +0000 (14:40 +0100)
Narrowing of Notification's implementedInterface() has introduced a few
places where we treat it as raw type. Fix mdsal-binding-dom-adapter's
offences.

Change-Id: Ie2bc9eb8bf9051ab2945f477fa99e88d0348421d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/AbstractDOMNotificationListenerAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMNotificationListenerAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMNotificationPublishServiceAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/LazySerializedDOMNotification.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/SingleBindingDOMNotificationAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/osgi/OSGiNotificationPublishService.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/NotificationListenerInvokerTest.java

index f85f2ab77710e88dd6bc3ad15e9787c9b0005c45..4740420f3fa96ff58e21ba5e4f71105f8835fa50 100644 (file)
@@ -31,11 +31,11 @@ abstract class AbstractDOMNotificationListenerAdapter implements DOMNotification
         onNotification(notification.getType(), verifyNotNull(deserialize(notification)));
     }
 
-    abstract void onNotification(@NonNull Absolute domType, @NonNull Notification notification);
+    abstract void onNotification(@NonNull Absolute domType, @NonNull Notification<?> notification);
 
     abstract Set<Absolute> getSupportedNotifications();
 
-    private Notification deserialize(final DOMNotification notification) {
+    private Notification<?> deserialize(final DOMNotification notification) {
         if (notification instanceof LazySerializedDOMNotification) {
             // TODO: This is a routed-back notification, for which we may end up losing event time here, but that is
             //       okay, for now at least.
index cf09f350ceaabfe33a12ba355a56a79fcfb6a045..28e5c631d3dfcc9f600d627cf86b02e82a39facf 100644 (file)
@@ -16,6 +16,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker;
 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yangtools.yang.binding.Notification;
@@ -24,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absol
 
 final class BindingDOMNotificationListenerAdapter extends AbstractDOMNotificationListenerAdapter {
     private final ImmutableMap<Absolute, NotificationListenerInvoker> invokers;
-    private final NotificationListener delegate;
+    private final @NonNull NotificationListener delegate;
 
     BindingDOMNotificationListenerAdapter(final AdapterContext adapterContext, final NotificationListener delegate) {
         super(adapterContext);
@@ -33,7 +34,7 @@ final class BindingDOMNotificationListenerAdapter extends AbstractDOMNotificatio
     }
 
     @Override
-    void onNotification(final Absolute domType, final Notification notification) {
+    void onNotification(final Absolute domType, final Notification<?> notification) {
         invokers.get(domType).invokeNotification(delegate, domType.lastNodeIdentifier(), notification);
     }
 
index 58c44c171ef54c60874f4c702a7759580c10ae1a..88c662866c7922d5c6abcd143207427f8f4a1ee2 100644 (file)
@@ -39,12 +39,12 @@ public class BindingDOMNotificationPublishServiceAdapter extends AbstractBinding
     }
 
     @Override
-    public void putNotification(final Notification notification) throws InterruptedException {
+    public void putNotification(final Notification<?> notification) throws InterruptedException {
         getDelegate().putNotification(toDomNotification(notification));
     }
 
     @Override
-    public ListenableFuture<? extends Object> offerNotification(final Notification notification) {
+    public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification) {
         ListenableFuture<?> offerResult = getDelegate().offerNotification(toDomNotification(notification));
         return DOMNotificationPublishService.REJECTED.equals(offerResult)
                 ? NotificationPublishService.REJECTED
@@ -52,8 +52,8 @@ public class BindingDOMNotificationPublishServiceAdapter extends AbstractBinding
     }
 
     @Override
-    public ListenableFuture<? extends Object> offerNotification(final Notification notification,
-                                                 final int timeout, final TimeUnit unit) throws InterruptedException {
+    public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification, final int timeout,
+            final TimeUnit unit) throws InterruptedException {
         ListenableFuture<?> offerResult = getDelegate().offerNotification(toDomNotification(notification), timeout,
             unit);
         return DOMNotificationPublishService.REJECTED.equals(offerResult)
@@ -61,7 +61,7 @@ public class BindingDOMNotificationPublishServiceAdapter extends AbstractBinding
                 : offerResult;
     }
 
-    private @NonNull DOMNotification toDomNotification(final Notification notification) {
+    private @NonNull DOMNotification toDomNotification(final Notification<?> notification) {
         final Instant instant = notification instanceof EventInstantAware
                 ? ((EventInstantAware) notification).eventInstant() : Instant.now();
         return LazySerializedDOMNotification.create(currentSerializer(), notification, instant);
index 84835579a42c4b84c3ad1c6d4cde1eb7b35eb9c5..6f56169aba3942b60eedbe0662a63e2afa276410 100644 (file)
@@ -44,13 +44,13 @@ final class LazySerializedDOMNotification implements DOMNotification, DOMEvent {
         });
 
     private final @NonNull BindingNormalizedNodeSerializer codec;
-    private final @NonNull Notification data;
+    private final @NonNull Notification<?> data;
     private final @NonNull Absolute type;
     private final @NonNull Instant eventInstant;
 
     private volatile ContainerNode domBody;
 
-    LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data,
+    LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification<?> data,
             final Absolute type, final Instant eventInstant) {
         this.codec = requireNonNull(codec);
         this.data = requireNonNull(data);
@@ -58,7 +58,7 @@ final class LazySerializedDOMNotification implements DOMNotification, DOMEvent {
         this.eventInstant = requireNonNull(eventInstant);
     }
 
-    static @NonNull DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data,
+    static @NonNull DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification<?> data,
             final Instant eventInstant) {
         final Absolute type = PATHS.getUnchecked(data.implementedInterface());
         return new LazySerializedDOMNotification(codec, data, type, eventInstant);
@@ -83,7 +83,7 @@ final class LazySerializedDOMNotification implements DOMNotification, DOMEvent {
         return eventInstant;
     }
 
-    @NonNull Notification getBindingData() {
+    @NonNull Notification<?> getBindingData() {
         return data;
     }
 }
index 9a7d002576d7499d4e1fda4da6f093f2c58d6d14..a4bb85f1e164039552998872bef34b6608c49a3e 100644 (file)
@@ -32,7 +32,7 @@ final class SingleBindingDOMNotificationAdapter<N extends Notification<N> & Data
     }
 
     @Override
-    void onNotification(final Absolute domType, final Notification notification) {
+    void onNotification(final Absolute domType, final Notification<?> notification) {
         executor.execute(() -> delegate.onNotification(type.cast(notification)));
     }
 
index 4232304867cbb7f0bcee0c5a73ac8b9bc9bec470..f46fa9b96e715d87cf20f44342191df2412e220f 100644 (file)
@@ -29,17 +29,17 @@ public final class OSGiNotificationPublishService extends AbstractAdaptedService
     }
 
     @Override
-    public void putNotification(final Notification notification) throws InterruptedException {
+    public void putNotification(final Notification<?> notification) throws InterruptedException {
         delegate().putNotification(notification);
     }
 
     @Override
-    public ListenableFuture<? extends Object> offerNotification(final Notification notification) {
+    public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification) {
         return delegate().offerNotification(notification);
     }
 
     @Override
-    public ListenableFuture<? extends Object> offerNotification(final Notification notification, final int timeout,
+    public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification, final int timeout,
             final TimeUnit unit) throws InterruptedException {
         return delegate().offerNotification(notification, timeout, unit);
     }
index 63417f389bb464dd57a45af59b6221ee8d58d33f..e8880d366702926da226a0ee4c2bbc1d3951a1ae 100644 (file)
@@ -17,6 +17,7 @@ import java.lang.invoke.MethodHandle;
 import java.lang.invoke.WrongMethodTypeException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -60,7 +61,7 @@ public class NotificationListenerInvokerTest {
         void onTestNotificationInterface(TestNotificationInterface notif);
     }
 
-    public interface TestNotificationInterface extends Notification {
+    public interface TestNotificationInterface extends DataObject, Notification<TestNotificationInterface> {
         QName QNAME = QName.create("test", "test");
     }
 }
\ No newline at end of file