sal-dom-broker: use lambdas
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / DOMNotificationRouter.java
index 41dfcb954909d10523ef0d05abca6b04f32abd32..2dc1d24369ccc5be75da82a2f6cb0b315402a55c 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
 import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableMultimap.Builder;
@@ -62,19 +61,10 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati
     private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouter.class);
     private static final ListenableFuture<Void> NO_LISTENERS = Futures.immediateFuture(null);
     private static final WaitStrategy DEFAULT_STRATEGY = PhasedBackoffWaitStrategy.withLock(1L, 30L, TimeUnit.MILLISECONDS);
-    private static final EventHandler<DOMNotificationRouterEvent> DISPATCH_NOTIFICATIONS = new EventHandler<DOMNotificationRouterEvent>() {
-        @Override
-        public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) throws Exception {
-            event.deliverNotification();
-
-        }
-    };
-    private static final EventHandler<DOMNotificationRouterEvent> NOTIFY_FUTURE = new EventHandler<DOMNotificationRouterEvent>() {
-        @Override
-        public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) {
-            event.setFuture();
-        }
-    };
+    private static final EventHandler<DOMNotificationRouterEvent> DISPATCH_NOTIFICATIONS =
+            (event, sequence, endOfBatch) -> event.deliverNotification();
+    private static final EventHandler<DOMNotificationRouterEvent> NOTIFY_FUTURE =
+            (event, sequence, endOfBatch) -> event.setFuture();
 
     private final Disruptor<DOMNotificationRouterEvent> disruptor;
     private final ExecutorService executor;
@@ -114,12 +104,7 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati
                 final ListenerRegistration<T> me = this;
 
                 synchronized (DOMNotificationRouter.this) {
-                    replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, new Predicate<ListenerRegistration<? extends DOMNotificationListener>>() {
-                        @Override
-                        public boolean apply(final ListenerRegistration<? extends DOMNotificationListener> input) {
-                            return input != me;
-                        }
-                    })));
+                    replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, input -> input != me)));
                 }
             }
         };
@@ -156,16 +141,12 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati
 
     private void notifyListenerTypesChanged(final Set<SchemaPath> typesAfter) {
         final List<ListenerRegistration<DOMNotificationSubscriptionListener>> listenersAfter =ImmutableList.copyOf(subscriptionListeners.getListeners());
-        executor.submit(new Runnable() {
-
-            @Override
-            public void run() {
-                for (final ListenerRegistration<DOMNotificationSubscriptionListener> subListener : listenersAfter) {
-                    try {
-                        subListener.getInstance().onSubscriptionChanged(typesAfter);
-                    } catch (final Exception e) {
-                        LOG.warn("Uncaught exception during invoking listener {}", subListener.getInstance(), e);
-                    }
+        executor.submit(() -> {
+            for (final ListenerRegistration<DOMNotificationSubscriptionListener> subListener : listenersAfter) {
+                try {
+                    subListener.getInstance().onSubscriptionChanged(typesAfter);
+                } catch (final Exception e) {
+                    LOG.warn("Uncaught exception during invoking listener {}", subListener.getInstance(), e);
                 }
             }
         });
@@ -175,13 +156,7 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati
     public <L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(
             final L listener) {
         final Set<SchemaPath> initialTypes = listeners.keySet();
-        executor.submit(new Runnable() {
-
-            @Override
-            public void run() {
-                listener.onSubscriptionChanged(initialTypes);
-            }
-        });
+        executor.submit(() -> listener.onSubscriptionChanged(initialTypes));
         return subscriptionListeners.registerWithType(listener);
     }