Provide a default port if the parsed string contained only a host. You can chain this after #fromString(String) to include a port in case the port was omitted from the input string. If a port was already provided, then this method is a no-op. @param defaultPort a port number, from [0..6553
(int defaultPort)
| 260 | |
| 261 | |
| 262 | public HostAndPort withDefaultPort(int defaultPort) { |
| 263 | checkArgument(isValidPort(defaultPort)); |
| 264 | if (hasPort() || port == defaultPort) { |
| 265 | return this; |
| 266 | } |
| 267 | return new HostAndPort(host, defaultPort, hasBracketlessColons); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Generate an error if the host might be a non-bracketed IPv6 literal. |
nothing calls this directly
no test coverage detected