sal-clustering-commons: use lambdas 82/57182/2
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:51:11 +0000 (17:51 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 16 May 2017 23:26:19 +0000 (23:26 +0000)
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: I2a4a800267cd00e9564dfa8b3af069fc14542f61
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailbox.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java

index c56863f..31feac2 100644 (file)
@@ -73,7 +73,7 @@ public class MeteredBoundedMailbox implements MailboxType,
     }
 
     private static Gauge<Integer> getQueueSizeGuage(final MeteredMessageQueue monitoredQueue) {
-        return () -> monitoredQueue.size();
+        return monitoredQueue::size;
     }
 
     private void registerQueueSizeMetric(String metricName, Gauge<Integer> metric) {
index d9b7adc..c89d7ff 100644 (file)
@@ -220,7 +220,7 @@ public class LocalSnapshotStore extends SnapshotStore {
 
         LOG.debug("Deleting files: {}", files);
 
-        files.forEach(file -> file.delete());
+        files.forEach(File::delete);
         return null;
     }
 
@@ -229,7 +229,7 @@ public class LocalSnapshotStore extends SnapshotStore {
 
         LOG.debug("Deleting files: {}", files);
 
-        files.forEach(file -> file.delete());
+        files.forEach(File::delete);
         return null;
     }
 
@@ -265,7 +265,7 @@ public class LocalSnapshotStore extends SnapshotStore {
     private Collection<SnapshotMetadata> getSnapshotMetadatas(final String persistenceId,
             final SnapshotSelectionCriteria criteria) {
         return getSnapshotFiles(persistenceId).stream().flatMap(file -> toStream(extractMetadata(file)))
-                .filter(md -> criteria.matches(md)).collect(Collectors.toList());
+                .filter(criteria::matches).collect(Collectors.toList());
     }
 
     private static Stream<SnapshotMetadata> toStream(@Nullable final SnapshotMetadata md) {
index d2e6b02..043aa46 100644 (file)
@@ -29,7 +29,7 @@ public class MeteredBoundedMailboxTest {
 
     @BeforeClass
     public static void setUp() throws Exception {
-        config = new CommonConfig.Builder<>("testsystem").withConfigReader(() -> ConfigFactory.load()).build();
+        config = new CommonConfig.Builder<>("testsystem").withConfigReader(ConfigFactory::load).build();
         actorSystem = ActorSystem.create("testsystem", config.get());
     }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.