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

Method withDefaultPort

output/java_guava/1.4.19/HostAndPort.java:262–268  ·  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

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.

Callers

nothing calls this directly

Calls 3

isValidPortMethod · 0.95
hasPortMethod · 0.95
checkArgumentMethod · 0.45

Tested by

no test coverage detected