Bug 611 - Added method which returns IpPrefix length. 09/7109/16
authorMartin Bobak <mbobak@cisco.com>
Thu, 29 May 2014 14:19:26 +0000 (16:19 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 9 Jun 2014 11:24:07 +0000 (13:24 +0200)
Change-Id: I722dbe6d42f7173bbf62dff5b3b32e5b17321211
Signed-off-by: Martin Bobak <mbobak@cisco.com>
concepts/src/main/java/org/opendaylight/protocol/concepts/Ipv4Util.java

index 18894f04d17afa280696ac7d0ee0957f607c60ea..435fad881a4edffe1da8e63cc84912078d71c90f 100644 (file)
@@ -136,7 +136,17 @@ public final class Ipv4Util {
         } else {
             p = prefix.getIpv6Prefix().getValue();
         }
-        final int sep = p.indexOf('/');
-        return Integer.valueOf(p.substring(sep + 1, p.length()));
+        return getPrefixLength(p);
+    }
+
+    /**
+     * Obtains prefix length from given prefix.
+     *
+     * @param prefixValue value of prefix
+     * @return prefix length
+     */
+    public static int getPrefixLength(final String prefixValue) {
+        final int sep = prefixValue.indexOf('/');
+        return Integer.valueOf(prefixValue.substring(sep + 1, prefixValue.length()));
     }
 }