@Test public void testToString() { assertEquals("foo:101", "" + HostAndPort.fromString("foo:101")); assertEquals(":102", HostAndPort.fromString(":102").toString()); assertEquals("[1::2]:103", HostAndPort.fromParts("1::2", 103).toString()); assertEquals("[::1]:104", HostAndPort.fromString("[::1]:104").toString()); assertEquals("foo", "" + HostAndPort.fromString("foo")); assertEquals("", HostAndPort.fromString("").toString()); assertEquals("[1::2]", HostAndPort.fromString("1::2").toString()); assertEquals("[::1]", HostAndPort.fromString("[::1]").toString()); assertEquals("[::]]:107", HostAndPort.fromParts("::]", 107).toString()); assertEquals("[[:]]:108", HostAndPort.fromString("[[:]]:108").toString()); }
@Override public String toString() { StringBuilder builder = new StringBuilder(host.length() + 8); if (host.indexOf(':') >= 0) { builder.append('[').append(host).append(']'); } else { builder.append(host); } if (hasPort()) { builder.append(':').append(port); } return builder.toString(); }
HostAndPort implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(host.length() + 8); if (host.indexOf(':') >= 0) { builder.append('[').append(host).append(']'); } else { builder.append(host); } if (hasPort()) { builder.append(':').append(port); } return builder.toString(); } }
HostAndPort implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(host.length() + 8); if (host.indexOf(':') >= 0) { builder.append('[').append(host).append(']'); } else { builder.append(host); } if (hasPort()) { builder.append(':').append(port); } return builder.toString(); } private  HostAndPort(String host, int port, boolean hasBracketlessColons); }
HostAndPort implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(host.length() + 8); if (host.indexOf(':') >= 0) { builder.append('[').append(host).append(']'); } else { builder.append(host); } if (hasPort()) { builder.append(':').append(port); } return builder.toString(); } private  HostAndPort(String host, int port, boolean hasBracketlessColons); String getHost(); boolean hasPort(); int getPort(); int getPortOrDefault(int defaultPort); static HostAndPort fromParts(String host, int port); static HostAndPort fromHost(String host); static HostAndPort fromString(String hostPortString); HostAndPort withDefaultPort(int defaultPort); HostAndPort requireBracketsForIPv6(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
HostAndPort implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(host.length() + 8); if (host.indexOf(':') >= 0) { builder.append('[').append(host).append(']'); } else { builder.append(host); } if (hasPort()) { builder.append(':').append(port); } return builder.toString(); } private  HostAndPort(String host, int port, boolean hasBracketlessColons); String getHost(); boolean hasPort(); int getPort(); int getPortOrDefault(int defaultPort); static HostAndPort fromParts(String host, int port); static HostAndPort fromHost(String host); static HostAndPort fromString(String hostPortString); HostAndPort withDefaultPort(int defaultPort); HostAndPort requireBracketsForIPv6(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }