Simplify DOMNotificationService contract 00/91500/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Jul 2020 10:24:30 +0000 (12:24 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Jul 2020 10:24:30 +0000 (12:24 +0200)
One of the methods can be implemented as a default method, making
things easier on implementations. Address the FIXME.

Change-Id: I99b2bc8c07a55b6a4e943f0185cdc6d29c8cf2fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMNotificationService.java
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/OSGiDOMNotificationRouter.java

index 3bbff670a8f53d948d18b8edce85115ad1e106a6..46f0f44a60bb49cc371844e250af0dc61884d775 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.mdsal.dom.api;
 
+import java.util.Arrays;
 import java.util.Collection;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -48,7 +49,8 @@ public interface DOMNotificationService extends DOMService {
      *         null or a SchemaPath which does not represent a valid {@link DOMNotification} type.
      * @throws NullPointerException if listener is null
      */
-    // FIXME: Java 8: provide a default implementation of this method.
-    <T extends DOMNotificationListener> ListenerRegistration<T>
-            registerNotificationListener(@NonNull T listener, SchemaPath... types);
+    default <T extends DOMNotificationListener> ListenerRegistration<T>
+            registerNotificationListener(@NonNull final T listener, final SchemaPath... types) {
+        return registerNotificationListener(listener, Arrays.asList(types));
+    }
 }
index 66bccef6d1bee5e29f5de1cc63cc536fbccb10e9..d7ee230c3b5ecafc25d2d0d45804298637431f6a 100644 (file)
@@ -23,7 +23,6 @@ import com.lmax.disruptor.PhasedBackoffWaitStrategy;
 import com.lmax.disruptor.WaitStrategy;
 import com.lmax.disruptor.dsl.Disruptor;
 import com.lmax.disruptor.dsl.ProducerType;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -138,12 +137,6 @@ public class DOMNotificationRouter implements AutoCloseable, DOMNotificationPubl
         return reg;
     }
 
-    @Override
-    public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
-            final T listener, final SchemaPath... types) {
-        return registerNotificationListener(listener, Arrays.asList(types));
-    }
-
     /**
      * Swaps registered listeners and triggers notification update.
      *
index 87ebcdb9a601eb53d0e7c40eed85f1267bcf7ad7..4adc9e01631c6ae14d3352119aec7d4e808bb024 100644 (file)
@@ -90,10 +90,4 @@ public final class OSGiDOMNotificationRouter implements DOMNotificationService,
             final Collection<SchemaPath> types) {
         return router.registerNotificationListener(listener, types);
     }
-
-    @Override
-    public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
-            final SchemaPath... types) {
-        return router.registerNotificationListener(listener, types);
-    }
 }