Improve ServerConfigurationPayload.equals() 62/105162/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Apr 2023 13:31:47 +0000 (15:31 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Apr 2023 13:59:15 +0000 (15:59 +0200)
Use pattern matching on instanceof to reduce verbosity while retaining
semantics.

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

index 4843063647eb6cc1d881a745c82c3e51da6b3d4e..02cb6fa37e7f8521bd4e917fb3828cf89a57d39f 100644 (file)
@@ -121,20 +121,8 @@ public final class ServerConfigurationPayload extends Payload implements Persist
 
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj == null) {
-            return false;
-        }
-
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-
-        ServerConfigurationPayload other = (ServerConfigurationPayload) obj;
-        return serverConfig.equals(other.serverConfig);
+        return this == obj || obj instanceof ServerConfigurationPayload other
+            && serverConfig.equals(other.serverConfig);
     }
 
     @Override