Use instanceof pattern in netconf-impl
[netconf.git] / netconf / netconf-impl / src / main / java / org / opendaylight / netconf / impl / NetconfServerSessionNegotiator.java
index 4af12fe78dad387b68207121602530bab13cc2bc..75ca014aac9877666ed21e478b21ee3241711bd2 100644 (file)
@@ -66,12 +66,11 @@ public final class NetconfServerSessionNegotiator
      * @return Two values - port and host of socket address
      */
     protected static Map.Entry<String, String> getHostName(final SocketAddress socketAddress) {
-        if (socketAddress instanceof InetSocketAddress) {
-            final var inetSocketAddress = (InetSocketAddress) socketAddress;
+        if (socketAddress instanceof InetSocketAddress inetSocketAddress) {
             return new SimpleImmutableEntry<>(Integer.toString(inetSocketAddress.getPort()),
                     inetSocketAddress.getHostString());
-        } else if (socketAddress instanceof LocalAddress) {
-            return new SimpleImmutableEntry<>(UNKNOWN, ((LocalAddress) socketAddress).id());
+        } else if (socketAddress instanceof LocalAddress localAddress) {
+            return new SimpleImmutableEntry<>(UNKNOWN, localAddress.id());
         } else {
             return new SimpleImmutableEntry<>(UNKNOWN, UNKNOWN);
         }