Merge "Cleanup use of Guava Function"
authorAnil Vishnoi <vishnoianil@gmail.com>
Thu, 27 Jun 2019 00:57:22 +0000 (00:57 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 27 Jun 2019 00:57:22 +0000 (00:57 +0000)
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/AbstractKarafTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ClearStatsCommandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ResetEventTimesComandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ResetSessionStatsComandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ShowEventTimesComandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ShowSessionStatsCommandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/karaf/ShowStatsCommandProviderTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java

index b6a0cc639370e0e3aa024f465752c21ece508a15..2486923e8dbc19b330d274514bd951d48e564f3e 100644 (file)
@@ -7,13 +7,11 @@
  */
 package org.opendaylight.openflowplugin.impl.device.initialization;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.Future;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@@ -53,7 +51,7 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
     private static final Logger LOG = LoggerFactory.getLogger(OF10DeviceInitializer.class);
 
     @Override
-    protected Future<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext,
+    protected ListenableFuture<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext,
                                                      final boolean switchFeaturesMandatory,
                                                      final boolean skipTableFeatures,
                                                      @Nullable final MultipartWriterProvider multipartWriterProvider,
@@ -91,13 +89,10 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
             }
         }, MoreExecutors.directExecutor());
 
-        return Futures.transform(future, new Function<Boolean, Void>() {
-            @Override
-            public Void apply(final Boolean input) {
-                LOG.debug("Writing physical port information for {}", deviceInfo);
-                writePhyPortInformation(deviceContext);
-                return null;
-            }
+        return Futures.transform(future, input -> {
+            LOG.debug("Writing physical port information for {}", deviceInfo);
+            writePhyPortInformation(deviceContext);
+            return null;
         }, MoreExecutors.directExecutor());
     }
 
index 68c6651e8bf9bb51c7722a1ef46c4401414e60f2..b75f99b208f385b661e6e8f12573c53828996ebd 100755 (executable)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics;
 
-import com.google.common.base.Function;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
@@ -173,7 +172,7 @@ public final class StatisticsGatheringUtils {
 
         try {
             Futures.transform(Futures.catchingAsync(future, Throwable.class, Futures::immediateFailedFuture,
-                MoreExecutors.directExecutor()), (Function<Optional<FlowCapableNode>, Void>) flowCapNodeOpt -> {
+                MoreExecutors.directExecutor()), flowCapNodeOpt -> {
                     // we have to read actual tables with all information before we set empty Flow list,
                     // merge is expensive and not applicable for lists
                     if (flowCapNodeOpt != null && flowCapNodeOpt.isPresent()) {
index bc2cac609ccd5dcd626baca4bbe903ff4edbfcf3..d47c0e1a38dea01b385af73e7b510316370a671b 100644 (file)
@@ -8,15 +8,15 @@
 
 package org.opendaylight.openflowplugin.impl.karaf;
 
-import com.google.common.base.Function;
 import java.io.PrintStream;
 import java.util.List;
+import java.util.function.Function;
 import org.apache.felix.service.command.CommandSession;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
 
 /**
  * Created by mirehak on 7/29/15.
index 50da77de1c68f54fe5101501ae6425864a3a71f1..f6bd07f75eee0353feb73a11b3da276150fdd62e 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.anyString;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -27,13 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class ClearStatsCommandProviderTest extends AbstractKarafTest {
 
     private ClearStatsCommandProvider clearStatsCommandProvider;
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.endsWith(": no activity detected");
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION =
+        input -> input.endsWith(": no activity detected");
     private MessageIntelligenceAgency mi5;
 
     @Override
index 8e0dc77bd08601acd202016956222cc3732d9bb6..02315e81251c7ac77b638aa47a49bc90bcc0dd02 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.anyString;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -25,16 +24,9 @@ import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCou
 public class ResetEventTimesComandProviderTest extends AbstractKarafTest {
 
     private ResetEventTimesComandProvider resetEventTimesComandProvider;
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.isEmpty();
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = String::isEmpty;
 
     @Override
-
     public void doSetUp() {
         resetEventTimesComandProvider = new ResetEventTimesComandProvider();
         EventsTimeCounter.resetAllCounters();
index c09a1605a43b295f968a4246ea2392d22b0128ea..754988938e45cac605955f72ee255100d3df11f7 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.anyString;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -24,16 +23,9 @@ import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.SessionStatis
 public class ResetSessionStatsComandProviderTest extends AbstractKarafTest {
 
     private ResetSessionStatsComandProvider resetSessionStatsComandProvider;
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.isEmpty();
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = String::isEmpty;
 
     @Override
-
     public void doSetUp() {
         resetSessionStatsComandProvider = new ResetSessionStatsComandProvider();
         SessionStatistics.resetAllCounters();
index f8f4804893bc24f7ff6984a86ae70becaf7319f9..69b0704d83030891127a67e1e4fdc047f52ec1a9 100644 (file)
@@ -5,13 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.contains;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -25,13 +23,7 @@ import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCou
 public class ShowEventTimesComandProviderTest extends AbstractKarafTest {
 
     private ShowEventTimesComandProvider showEventTimesComandProvider;
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.isEmpty();
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = String::isEmpty;
 
     @Override
 
index 20508355d9f4ad949219b3bfb371472c8fda7640..5571901276b836ef86d117ba0736e6b691717863 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.contains;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -24,13 +23,7 @@ import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.SessionStatis
 public class ShowSessionStatsCommandProviderTest extends AbstractKarafTest {
 
     private ShowSessionStatsCommandProvider showSessionStatsCommandProvider;
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.isEmpty();
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = String::isEmpty;
 
     @Override
 
index 870f233a6859386c2859380932a86266a2b801c8..f9bb9763bff07a459c804d52548770420708ab43 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.karaf;
 
 import static org.mockito.ArgumentMatchers.matches;
 
-import com.google.common.base.Function;
-import javax.annotation.Nullable;
+import java.util.function.Function;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
@@ -29,13 +28,8 @@ public class ShowStatsCommandProviderTest extends AbstractKarafTest {
     private ShowStatsCommandProvider showStatsCommandProvider;
     private MessageIntelligenceAgency messageIntelligenceAgency;
 
-    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION = new Function<String, Boolean>() {
-        @Nullable
-        @Override
-        public Boolean apply(String input) {
-            return input.endsWith(": no activity detected");
-        }
-    };
+    private static final Function<String, Boolean> CHECK_NO_ACTIVITY_FUNCTION =
+        input -> input.endsWith(": no activity detected");
 
     @Override
     public void doSetUp() {
@@ -76,4 +70,4 @@ public class ShowStatsCommandProviderTest extends AbstractKarafTest {
         Assert.assertFalse(checkNoActivity(messageIntelligenceAgency.provideIntelligence(),
                 CHECK_NO_ACTIVITY_FUNCTION));
     }
-}
\ No newline at end of file
+}
index dc5034b5f3f876d5636c5a5fbd88f744cae632e5..2c6a45b14b59be41974e5b00de6427dee863a8b5 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.openflowplugin.impl.util;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 import java.util.Collections;
 import java.util.List;
+import java.util.function.Function;
 import org.apache.commons.lang3.tuple.Pair;
 import org.junit.Assert;
 import org.junit.Test;