From: Stephen Kitt Date: Tue, 16 May 2017 15:50:58 +0000 (+0200) Subject: sal-binding-it: use lambdas X-Git-Tag: release/nitrogen~214 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e4550bea5b9d5589b1937d5a4496abde2f476b2e;hp=1da4f8be48cca9621b790c486528bb28c1cae0c7 sal-binding-it: use lambdas This series of patches uses lambdas instead of anonymous classes for functional interfaces when possible. Lambdas are replaced with method references when appropriate. Change-Id: I714b8b5499f6fe5d6f2b2172b59bfba10678bae4 Signed-off-by: Stephen Kitt --- diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java index 717aa63811..fc92567ed5 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java @@ -13,7 +13,6 @@ import static org.junit.Assert.assertNull; import java.util.concurrent.Future; import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; @@ -42,13 +41,7 @@ public class DataServiceIT extends AbstractIT { */ @Test public void test() throws Exception { - BindingAwareConsumer consumer = new BindingAwareConsumer() { - - @Override - public void onSessionInitialized(final ConsumerContext session) { - consumerDataService = session.getSALService(DataBrokerService.class); - } - }; + BindingAwareConsumer consumer = session -> consumerDataService = session.getSALService(DataBrokerService.class); broker.registerConsumer(consumer); diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java index 1a950a1062..db978dbeec 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import org.junit.Test; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; @@ -64,13 +63,10 @@ public class NotificationIT extends AbstractIT { LOG.info("The registration of the Consumer 1. It retrieves Notification Service " + "from MD-SAL and registers OpendaylightTestNotificationListener as notification listener"); - BindingAwareConsumer consumer1 = new BindingAwareConsumer() { - @Override - public void onSessionInitialized(ConsumerContext session) { - NotificationService notificationService = session.getSALService(NotificationService.class); - assertNotNull(notificationService); - listener1Reg = notificationService.registerNotificationListener(listener1); - } + BindingAwareConsumer consumer1 = session -> { + NotificationService notificationService = session.getSALService(NotificationService.class); + assertNotNull(notificationService); + listener1Reg = notificationService.registerNotificationListener(listener1); }; // registerConsumer method calls onSessionInitialized method above broker.registerConsumer(consumer1); @@ -93,14 +89,8 @@ public class NotificationIT extends AbstractIT { LOG.info("The registration of the Consumer 2. SalFlowListener is registered " + "registered as notification listener."); - BindingAwareProvider provider = new BindingAwareProvider() { - - @Override - public void onSessionInitiated(ProviderContext session) { - listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener( - listener2); - } - }; + BindingAwareProvider provider = session -> listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener( + listener2); // registerConsumer method calls onSessionInitialized method above broker.registerProvider(provider); diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java index 0b365cac49..a394bcba89 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java @@ -17,7 +17,6 @@ import com.google.common.util.concurrent.Futures; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; @@ -96,12 +95,8 @@ public class RoutedServiceIT extends AbstractIT { assertSame(odlRoutedService2, secondReg.getInstance()); assertNotSame(secondReg, firstReg); - final BindingAwareConsumer consumer = new BindingAwareConsumer() { - @Override - public void onSessionInitialized(final ConsumerContext session) { - consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class); - } - }; + final BindingAwareConsumer consumer = + session -> consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class); LOG.info("Register routeService consumer"); broker.registerConsumer(consumer);