public static NetworkEndpoint forHostnameAndPort(String hostname, int port) {
    checkArgument(
        0 <= port && port <= MAX_PORT_NUMBER,
        "Port out of range. Expected [0, %s], actual %s.",
        MAX_PORT_NUMBER,
        port);

    return forHostname(hostname).toBuilder()
        .setType(NetworkEndpoint.Type.HOSTNAME_PORT)
        .setPort(Port.newBuilder().setPortNumber(port))
        .build();
  }
@Test
  public void forHostnameAndPort_withHostnameAndPort_returnsHostnameAndPortNetworkEndpoint() {
    assertThat(NetworkEndpointUtils.forHostnameAndPort("localhost", 8888))
        .isEqualTo(
            NetworkEndpoint.newBuilder()
                .setType(NetworkEndpoint.Type.HOSTNAME_PORT)
                .setPort(Port.newBuilder().setPortNumber(8888))
                .setHostname(Hostname.newBuilder().setName("localhost"))
                .build());
  }