public static NetworkEndpoint forHostname(String hostname) {
    checkArgument(
        !InetAddresses.isInetAddress(hostname), "Expected hostname, got IP address '%s'", hostname);

    return NetworkEndpoint.newBuilder()
        .setType(NetworkEndpoint.Type.HOSTNAME)
        .setHostname(Hostname.newBuilder().setName(hostname))
        .build();
  }
@Test
  public void forHostname_withIpAddress_throwsIllegalArgumentException() {
    assertThrows(IllegalArgumentException.class, () -> NetworkEndpointUtils.forHostname("1.2.3.4"));
    assertThrows(IllegalArgumentException.class, () -> NetworkEndpointUtils.forHostname("3ffe::1"));
  }