public static boolean isValidIp(String ip) {
    return ip != null && (parseV4(ip) != null || parseV6(ip) != null);
  }
@Test
  public void testIsValidIp() {
    assertTrue(Hosts.isValidIp("127.0.0.1"));
    assertTrue(Hosts.isValidIp("0.0.0.0"));
    assertFalse(Hosts.isValidIp("324.0.0.1"));
    assertFalse(Hosts.isValidIp("127.0.0."));
    assertFalse(Hosts.isValidIp("127.0.0"));
    assertFalse(Hosts.isValidIp("-1.0.0"));
    assertFalse(Hosts.isValidIp(""));
    assertFalse(Hosts.isValidIp(null));
  }