Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / netconf-console / src / main / java / org / opendaylight / netconf / console / commands / NetconfCommandUtils.java
index 67024f910b005a9c8d4c28742c87761a4516c454..f705c94062021b393c5b1d72aa1618ef0143720b 100644 (file)
@@ -8,28 +8,33 @@
 
 package org.opendaylight.netconf.console.commands;
 
+import com.google.common.base.Strings;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import com.google.common.base.Strings;
-
-public class NetconfCommandUtils {
+public final class NetconfCommandUtils {
 
     private static final Pattern IP_PATTERN = Pattern.compile(
-            "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
-                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
-                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
-                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
+            "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+                    + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+                    + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+                    + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
+
+    private NetconfCommandUtils() {
+
+    }
 
     public static boolean isPortValid(final String devicePort) {
         if (Strings.isNullOrEmpty(devicePort)) {
             return false;
         }
-        Integer port = Integer.parseInt(devicePort);
-        if (port != null && port >= 0 && port <= 65535) {
-            return true;
+        Integer port;
+        try {
+            port = Integer.parseInt(devicePort);
+        } catch (NumberFormatException e) {
+            return false;
         }
-        return false;
+        return port >= 0 && port <= 65535;
     }
 
     public static boolean isIpValid(final String deviceIp) {