MCPcopy Create free account
hub / github.com/antlr/codebuff / withDefaultPort

Method withDefaultPort

corpus/java/training/guava/net/HostAndPort.java:253–259  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

251 * @return a HostAndPort instance, guaranteed to have a defined port.
252 */
253 public HostAndPort withDefaultPort(int defaultPort) {
254 checkArgument(isValidPort(defaultPort));
255 if (hasPort() || port == defaultPort) {
256 return this;
257 }
258 return new HostAndPort(host, defaultPort, hasBracketlessColons);
259 }
260
261 /**
262 * Generate an error if the host might be a non-bracketed IPv6 literal.

Callers

nothing calls this directly

Calls 3

isValidPortMethod · 0.95
hasPortMethod · 0.95
checkArgumentMethod · 0.45

Tested by

no test coverage detected