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 Summary
-
Method Summary
Modifier and Type Method Description booleanequals(Object o)StringgetHostText()intgetPort()inthashCode()booleanhasPort()static HostAndPortof(String host, int port)static HostAndPortparse(String hostPortString)Parse a host and port string into aHostAndPort.static HostAndPortparseCompat(String hostAndPortPart)Temporary workaround until Redis provides IPv6 addresses in bracket notation.StringtoString()
-
Field Details
-
hostText
-
port
public final int port
-
-
Method Details
-
of
- Parameters:
host- the hostnameport- a valid port- Returns:
- the
HostAndPortofhostandport
-
parse
- Parameters:
hostPortString-- Returns:
-
parseCompat
Temporary workaround until Redis provides IPv6 addresses in bracket notation. Allows parsing of1.2.3.4:6479anddead:beef:dead:beef:affe::1:6379into 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:
trueif has a port.
-
getHostText
- Returns:
- the host text.
-
getPort
public int getPort()- Returns:
- the port.
-
equals
-
hashCode
public int hashCode() -
toString
-