@Test public void testGetIpAddrFromPrefix_Ipv4Prefix () { String result = NetUtils.getIpAddrFromPrefix(IPV4_ADDRESS_1 + MASK_24); Assert.assertEquals(IPV4_ADDRESS_1, result); }
public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); }
NetUtils { public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); } }
NetUtils { public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); }  }
NetUtils { public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); }  static int getMaskFromPrefix(@Nullable String prefix); static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix); static @Nullable Ipv6Address applyMaskOnIpv6Prefix(@Nullable Ipv6Prefix ipv6Prefix, int ipv6MaskLength); static @Nullable Ipv6Address applyMaskOnIpv6Address(@Nullable Ipv6Address ipv6Address, int ipv6MaskLength); static boolean samePrefix(@Nullable IpPrefix prefix1, @Nullable IpPrefix prefix2); static boolean isInRange(@Nullable IpPrefix prefix, @Nullable String ipAddress); }
NetUtils { public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); }  static int getMaskFromPrefix(@Nullable String prefix); static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix); static @Nullable Ipv6Address applyMaskOnIpv6Prefix(@Nullable Ipv6Prefix ipv6Prefix, int ipv6MaskLength); static @Nullable Ipv6Address applyMaskOnIpv6Address(@Nullable Ipv6Address ipv6Address, int ipv6MaskLength); static boolean samePrefix(@Nullable IpPrefix prefix1, @Nullable IpPrefix prefix2); static boolean isInRange(@Nullable IpPrefix prefix, @Nullable String ipAddress);  }