Endpoint implements Comparable<Endpoint>, EndpointGroup { public static Endpoint parse(String authority) { requireNonNull(authority, "authority"); final HostAndPort parsed = HostAndPort.fromString(removeUserInfo(authority)).withDefaultPort(0); return create(parsed.getHost(), parsed.getPort()); } private  Endpoint(String host, @Nullable String ipAddr, int port, int weight, HostType hostType); static Endpoint parse(String authority); static Endpoint of(String host, int port); static Endpoint of(String host); @Override List<Endpoint> endpoints(); @Override EndpointSelectionStrategy selectionStrategy(); @Override Endpoint selectNow(ClientRequestContext ctx); @Override CompletableFuture<Endpoint> select(ClientRequestContext ctx,
                                              ScheduledExecutorService executor,
                                              long timeoutMillis); @Override CompletableFuture<List<Endpoint>> whenReady(); String host(); @Nullable String ipAddr(); boolean hasIpAddr(); boolean isIpAddrOnly(); @Nullable StandardProtocolFamily ipFamily(); int port(); int port(int defaultValue); boolean hasPort(); Endpoint withPort(int port); Endpoint withoutPort(); Endpoint withDefaultPort(int defaultPort); Endpoint withoutDefaultPort(int defaultPort); Endpoint withIpAddr(@Nullable String ipAddr); Endpoint withWeight(int weight); int weight(); String authority(); URI toUri(String scheme); URI toUri(String scheme, @Nullable String path); URI toUri(SessionProtocol sessionProtocol); URI toUri(SessionProtocol sessionProtocol, @Nullable String path); URI toUri(Scheme scheme); URI toUri(Scheme scheme, @Nullable String path); @Override CompletableFuture<?> closeAsync(); @Override void close(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @Override int compareTo(Endpoint that); @Override String toString();  }
@Test void parse() { final Endpoint foo = Endpoint.parse("foo"); assertThat(foo).isEqualTo(Endpoint.of("foo")); assertThatThrownBy(foo::port).isInstanceOf(IllegalStateException.class); assertThat(foo.weight()).isEqualTo(1000); assertThat(foo.ipAddr()).isNull(); assertThat(foo.ipFamily()).isNull(); assertThat(foo.hasIpAddr()).isFalse(); assertThat(foo.hasPort()).isFalse(); assertThat(foo.toUri("none+http").toString()).isEqualTo("none+http: final Endpoint bar = Endpoint.parse("bar:80"); assertThat(bar).isEqualTo(Endpoint.of("bar", 80)); assertThat(bar.port()).isEqualTo(80); assertThat(bar.weight()).isEqualTo(1000); assertThat(bar.ipAddr()).isNull(); assertThat(bar.ipFamily()).isNull(); assertThat(bar.hasIpAddr()).isFalse(); assertThat(bar.hasPort()).isTrue(); assertThat(bar.toUri("none+http").toString()).isEqualTo("none+http: final Endpoint barWithUserInfo = Endpoint.parse("foo@bar:80"); assertThat(barWithUserInfo).isEqualTo(Endpoint.of("bar", 80)); assertThat(barWithUserInfo.port()).isEqualTo(80); assertThat(barWithUserInfo.weight()).isEqualTo(1000); assertThat(barWithUserInfo.ipAddr()).isNull(); assertThat(barWithUserInfo.ipFamily()).isNull(); assertThat(barWithUserInfo.hasIpAddr()).isFalse(); assertThat(barWithUserInfo.hasPort()).isTrue(); assertThat(barWithUserInfo.toUri("none+http").toString()).isEqualTo("none+http: }