Interface HostAndPort


public interface HostAndPort
A tuple of <host name, port>.
  • Method Details

    • hostName

      String hostName()
      Returns the host name.
      Returns:
      The hostname
    • port

      int port()
      Returns the port.
      Returns:
      The port
    • of

      static HostAndPort of(String host, int port)
      Returns a HostAndPort object for the specified values.
      Parameters:
      host - host name
      port - port
      Returns:
      the HostAndPort
    • of

      static HostAndPort of(InetSocketAddress address)
      Create a new HostAndPort from a InetSocketAddress.

      Note that creation of a InetSocketAddress may use the JDK's blocking DNS resolution. Take care to only create these objects if you intend to use the JDK's blocking DNS resolution, and you are safe to block.

      Parameters:
      address - The InetSocketAddress to convert.
      Returns:
      the HostAndPort.
    • ofIpPort

      static HostAndPort ofIpPort(String ipPort)
      Parse IPv4 xxx.xxx.xxx.xxx:yyyyy and IPv6 [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:yyyyy style addresses.
      Parameters:
      ipPort - An IPv4 xxx.xxx.xxx.xxx:yyyyy or IPv6 [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:yyyyy addresses.
      Returns:
      A HostAndPort where the hostname is the IP address and the port is parsed from the string.
      See Also:
    • ofIpPort

      static HostAndPort ofIpPort(String ipPort, int startIndex)
      Parse IPv4 xxx.xxx.xxx.xxx:yyyyy and IPv6 [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:yyyyy style addresses.
      Parameters:
      ipPort - An IPv4 xxx.xxx.xxx.xxx:yyyyy or IPv6 [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:yyyyy addresses.
      startIndex - The index at which the address parsing starts.
      Returns:
      A HostAndPort where the hostname is the IP address and the port is parsed from the string.