More pattern matching 11/101311/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 26 May 2022 20:51:47 +0000 (22:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 26 May 2022 20:51:47 +0000 (22:51 +0200)
Remove mulitple casts in favor of instanceof pattern match.

Change-Id: I301a00ec98127c2e5f6ae2326d95fd68c8e31ad0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java

index 5be865f..904c7ba 100644 (file)
@@ -153,20 +153,18 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
                 return;
             }
 
-            if (message instanceof ServerConfigurationPayload) {
-                super.persistData(collectorActor, new MockIdentifier("serverConfig"), (Payload) message, false);
+            if (message instanceof ServerConfigurationPayload payload) {
+                super.persistData(collectorActor, new MockIdentifier("serverConfig"), payload, false);
                 return;
             }
 
-            if (message instanceof SetPeerAddress) {
-                setPeerAddress(((SetPeerAddress) message).getPeerId(),
-                        ((SetPeerAddress) message).getPeerAddress());
+            if (message instanceof SetPeerAddress setPeerAddress) {
+                setPeerAddress(setPeerAddress.getPeerId(), setPeerAddress.getPeerAddress());
                 return;
             }
 
-            if (message instanceof TestPersist) {
-                persistData(((TestPersist) message).getActorRef(), ((TestPersist) message).getIdentifier(),
-                        ((TestPersist) message).getPayload(), false);
+            if (message instanceof TestPersist testPersist) {
+                persistData(testPersist.getActorRef(), testPersist.getIdentifier(), testPersist.getPayload(), false);
                 return;
             }