Module lettuce.core

Class HostAndPort

java.lang.Object
io.lettuce.core.internal.HostAndPort

public class HostAndPort
extends Object
An immutable representation of a host and port.
Since:
4.2
Author:
Mark Paluch, Larry Battle
  • Field Details

    • hostText

      public final String hostText
    • port

      public final int port
  • Method Details

    • of

      public static HostAndPort of​(String host, int port)
      Create a HostAndPort of host and port
      Parameters:
      host - the hostname
      port - a valid port
      Returns:
      the HostAndPort of host and port
    • parse

      public static HostAndPort parse​(String hostPortString)
      Parse a host and port string into a HostAndPort. The port is optional. Examples: host:port or host
      Parameters:
      hostPortString -
      Returns:
    • parseCompat

      public static HostAndPort parseCompat​(String hostAndPortPart)
      Temporary workaround until Redis provides IPv6 addresses in bracket notation. Allows parsing of 1.2.3.4:6479 and dead:beef:dead:beef:affe::1:6379 into host and port. We assume the last item after the colon is a port.
      Parameters:
      hostAndPortPart - the string containing the host and port
      Returns:
      the parsed HostAndPort.
    • hasPort

      public boolean hasPort()
      Returns:
      true if has a port.
    • getHostText

      public String getHostText()
      Returns:
      the host text.
    • getPort

      public int getPort()
      Returns:
      the port.
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object