Use instanceof pattern in RemoteNetconfCommand 26/101726/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jul 2022 20:31:12 +0000 (22:31 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Jul 2022 02:12:30 +0000 (04:12 +0200)
Remove duplicate casts, improving expressiveness.

Change-Id: I662686d163217a28d8d1c2d44e8ad1f7c3a7de4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java

index d9ef852404eeaa11df5248841eb95ecceb558643..de2251f6a003f37a37660975c5724904a6bdaf5c 100644 (file)
@@ -108,9 +108,9 @@ public class RemoteNetconfCommand implements AsyncCommand {
         final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress();
         final String hostName;
         final String port;
-        if (remoteAddress instanceof InetSocketAddress) {
-            hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
-            port = Integer.toString(((InetSocketAddress) remoteAddress).getPort());
+        if (remoteAddress instanceof InetSocketAddress remoteInetAddress) {
+            hostName = remoteInetAddress.getAddress().getHostAddress();
+            port = Integer.toString(remoteInetAddress.getPort());
         } else {
             hostName = "";
             port = "";