Package io.lettuce.core.internal
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getHostText()
int
getPort()
int
hashCode()
boolean
hasPort()
static HostAndPort
of(String host, int port)
static HostAndPort
parse(String hostPortString)
Parse a host and port string into aHostAndPort
.static HostAndPort
parseCompat(String hostAndPortPart)
Temporary workaround until Redis provides IPv6 addresses in bracket notation.String
toString()
-
-
-
Field Detail
-
hostText
public final String hostText
-
port
public final int port
-
-
Method Detail
-
of
public static HostAndPort of(String host, int port)
- Parameters:
host
- the hostnameport
- a valid port- Returns:
- the
HostAndPort
ofhost
andport
-
parse
public static HostAndPort parse(String hostPortString)
- Parameters:
hostPortString
-- Returns:
-
parseCompat
public static HostAndPort parseCompat(String hostAndPortPart)
Temporary workaround until Redis provides IPv6 addresses in bracket notation. Allows parsing of1.2.3.4:6479
anddead: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.
-
-