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_withHostname_returnsHostnameNetworkEndpoint() {
    assertThat(NetworkEndpointUtils.forHostname("localhost"))
        .isEqualTo(
            NetworkEndpoint.newBuilder()
                .setType(NetworkEndpoint.Type.HOSTNAME)
                .setHostname(Hostname.newBuilder().setName("localhost"))
                .build());
  }