@Test public void testgetIpVersionOfIpTrue() { assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2001:db8:85a3:0:2001:6a8:0:2")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("fe80::1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::192.168.1.1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("0:0:0:0:0:0:0:0")); assertEquals( IpVersion.V6, IpUtil.getIpVersionOfIp("ffff:FFFF:fffF:Ffff:fFFF:FFff:ffFF:FFFf")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1080::8:800:2C:4A")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("FEC0:0:0:0:0:0:0:1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::FFFF:192.168.1.1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("abcd:ef:111:f123::1")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1138:0:0:0:8:80:800:417A")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("fecc:face::b00c:f001:fedc:fedd")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("CaFe:BaBe:dEAd:BeeF:12:345:6789:abcd")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::1:a:B:C:d:e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1::a:B:C:d:e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a::B:C:d:e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B::C:d:e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B:C::d:e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B:C:d::e:f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B:C:d:e::f")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B:C:d:e:f::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::2:f:E:D:6:7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2::f:E:D:6:7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2:f::E:D:6:7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2:f:E::D:6:7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2:f:E:D::6:7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2:f:E:D:6::7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2:f:E:D:6:7::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::3:A:b:8:0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("3::A:b:8:0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("3:A::b:8:0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("3:A:b::8:0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("3:A:b:8::0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("3:A:b:8:0::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::4:5:C:d")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("4::5:C:d")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("4:5::C:d")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("4:5:C::d")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("4:5:C:d::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::5:e:F")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("5::e:F")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("5:e::F")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("5:e:F::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::6:A")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("6::A")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("6:A::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("7::")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::7")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("1:a:B:C:d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::a:B:C:d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("a::B:C:d:2:0.0.0.0")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("a:B::C:d:2:255.255.255.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("a:B:C::d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("a:B:C:d::2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("a:B:C:d:2::255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::B:C:d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("B::C:d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("B:C::d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("B:C:d::2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("B:C:d:2::255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::C:d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("C::d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("C:d::2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("C:d:2::255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::d:2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("d::2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("d:2::255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::2:255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("2::255.0.0.255")); assertEquals(IpVersion.V6, IpUtil.getIpVersionOfIp("::255.0.0.255")); }
public static IpVersion getIpVersionOfIp(String ipPrefix) { if (StringUtils.isBlank(ipPrefix)) { return IpVersion.INVALID; } if (StringUtils.contains(ipPrefix, "/")) { return IpVersion.INVALID; } IpVersion ipVersion = getIpVersionOfNetwork(ipPrefix); return ipVersion; }
IpUtil { public static IpVersion getIpVersionOfIp(String ipPrefix) { if (StringUtils.isBlank(ipPrefix)) { return IpVersion.INVALID; } if (StringUtils.contains(ipPrefix, "/")) { return IpVersion.INVALID; } IpVersion ipVersion = getIpVersionOfNetwork(ipPrefix); return ipVersion; } }
IpUtil { public static IpVersion getIpVersionOfIp(String ipPrefix) { if (StringUtils.isBlank(ipPrefix)) { return IpVersion.INVALID; } if (StringUtils.contains(ipPrefix, "/")) { return IpVersion.INVALID; } IpVersion ipVersion = getIpVersionOfNetwork(ipPrefix); return ipVersion; } private  IpUtil(); }
IpUtil { public static IpVersion getIpVersionOfIp(String ipPrefix) { if (StringUtils.isBlank(ipPrefix)) { return IpVersion.INVALID; } if (StringUtils.contains(ipPrefix, "/")) { return IpVersion.INVALID; } IpVersion ipVersion = getIpVersionOfNetwork(ipPrefix); return ipVersion; } private  IpUtil(); static IpInBytes parseIp(String ip, IpVersion ipVersion); static int getHexCharSize(IpVersion ipVersion); static IpVersion getIpVersionOfNetwork(String cidr); static NetworkInBytes parseNetwork(String cidr, IpVersion ipVersion); static NetworkInBytes parseNetworkV6(String cidr); static NetworkInBytes parseNetworkV4(String cidr); static byte[] ipToByteArray(String ipPrefix, IpVersion ipVersion); static byte[] ipToByteArray(String ipPrefix); static IpVersion getIpVersionOfIp(String ipPrefix); static String toString(byte[] bytes, IpVersion ipVersion); static String addNetworkMaskIfNotContainsMask(String cidr); static String generateNetworkRangeSql(String ipColumnName,
            String ipVersionColumnName); static String generateNetworkVersionSql(String ipVersionColumnName); }
IpUtil { public static IpVersion getIpVersionOfIp(String ipPrefix) { if (StringUtils.isBlank(ipPrefix)) { return IpVersion.INVALID; } if (StringUtils.contains(ipPrefix, "/")) { return IpVersion.INVALID; } IpVersion ipVersion = getIpVersionOfNetwork(ipPrefix); return ipVersion; } private  IpUtil(); static IpInBytes parseIp(String ip, IpVersion ipVersion); static int getHexCharSize(IpVersion ipVersion); static IpVersion getIpVersionOfNetwork(String cidr); static NetworkInBytes parseNetwork(String cidr, IpVersion ipVersion); static NetworkInBytes parseNetworkV6(String cidr); static NetworkInBytes parseNetworkV4(String cidr); static byte[] ipToByteArray(String ipPrefix, IpVersion ipVersion); static byte[] ipToByteArray(String ipPrefix); static IpVersion getIpVersionOfIp(String ipPrefix); static String toString(byte[] bytes, IpVersion ipVersion); static String addNetworkMaskIfNotContainsMask(String cidr); static String generateNetworkRangeSql(String ipColumnName,
            String ipVersionColumnName); static String generateNetworkVersionSql(String ipVersionColumnName); static final int RADIX_HEX; static final int RADIX_DECIMAL; }