sal-akka-raft: use lambdas 76/57176/2
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:49:25 +0000 (17:49 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 16 May 2017 23:28:05 +0000 (23:28 +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: I1c48105a90efa73c1cb7ae2fba9111f74951fe11
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/IsolationScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java

index c58d6f9..9560665 100644 (file)
@@ -30,7 +30,7 @@ abstract class TimedRunnable implements Runnable {
         Preconditions.checkNotNull(timeout);
         Preconditions.checkNotNull(actor);
         cancelTimer = actor.getContext().system().scheduler().scheduleOnce(timeout, actor.self(),
-                (Runnable) () -> cancel(), actor.getContext().system().dispatcher(), actor.self());
+                (Runnable) this::cancel, actor.getContext().system().dispatcher(), actor.self());
     }
 
     @Override
index 1d7e317..fb810e3 100644 (file)
@@ -160,15 +160,13 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Wait for the isolated leader to send AppendEntries to the followers with the new entry with index 1. This
         // message is forwarded to the followers.
 
-        expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
-                    && ae.getEntries().get(0).getData().equals(payload1);
-        });
+        expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae ->
+                ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                        && ae.getEntries().get(0).getData().equals(payload1));
 
-        expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
-                    && ae.getEntries().get(0).getData().equals(payload1);
-        });
+        expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae ->
+                ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                        && ae.getEntries().get(0).getData().equals(payload1));
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
 
@@ -283,15 +281,13 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Wait for the isolated leader to send AppendEntries to the followers with the new entry with index 1. This
         // message is forwarded to the followers.
 
-        expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
-                    && ae.getEntries().get(0).getData().equals(payload1);
-        });
+        expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae ->
+                ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                        && ae.getEntries().get(0).getData().equals(payload1));
 
-        expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
-                    && ae.getEntries().get(0).getData().equals(payload1);
-        });
+        expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae ->
+                ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                        && ae.getEntries().get(0).getData().equals(payload1));
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
 
index c3d33e1..a8ecf71 100644 (file)
@@ -741,7 +741,7 @@ public class LeaderTest extends AbstractLeaderTest<Leader> {
         actorContext.getReplicatedLog().removeFrom(0);
 
         AtomicReference<java.util.Optional<OutputStream>> installSnapshotStream = new AtomicReference<>();
-        actorContext.setCreateSnapshotProcedure(out -> installSnapshotStream.set(out));
+        actorContext.setCreateSnapshotProcedure(installSnapshotStream::set);
 
         leader = new Leader(actorContext);
         actorContext.setCurrentBehavior(leader);

©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.