public class ConnectionEndpoint extends Object implements Cloneable, Comparable<ConnectionEndpoint>
Cloneable
,
Comparable
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_HOST |
protected static int |
DEFAULT_PORT |
Constructor and Description |
---|
ConnectionEndpoint(String host,
int port)
Constructs a ConnectionEndpoint initialized with the specific host and port.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
clone() |
int |
compareTo(ConnectionEndpoint connectionEndpoint) |
boolean |
equals(Object obj) |
static ConnectionEndpoint |
from(InetSocketAddress socketAddress)
Converts the InetSocketAddress into a ConnectionEndpoint.
|
String |
getHost()
Gets the host in this ConnectionEndpoint.
|
int |
getPort()
Gets the port number in this ConnectionEndpoint.
|
int |
hashCode() |
static ConnectionEndpoint |
parse(String hostPort)
Parses the host and port String value into a valid ConnectionEndpoint.
|
static ConnectionEndpoint |
parse(String hostPort,
int defaultPort)
Parses the host and port value into a valid ConnectionEndpoint.
|
InetSocketAddress |
toInetSocketAddress()
Converts this
ConnectionEndpoint into an InetSocketAddress representation. |
String |
toString() |
protected static final int DEFAULT_PORT
protected static final String DEFAULT_HOST
public ConnectionEndpoint(String host, int port)
host
- the hostname or IP address of the ConnectionEndpoint. If the host is unspecified,
then ConnectionEndpoint.DEFAULT_HOST will be used.port
- the (service) port number in this ConnectionEndpoint.IllegalArgumentException
- if the port number is less than 0.DEFAULT_HOST
public static ConnectionEndpoint from(InetSocketAddress socketAddress)
socketAddress
- the InetSocketAddress used to construct and initialize the ConnectionEndpoint.InetSocketAddress
public static ConnectionEndpoint parse(String hostPort)
hostPort
- a String value containing the host and port formatted as 'host[port]'.parse(String, int)
,
DEFAULT_PORT
public static ConnectionEndpoint parse(String hostPort, int defaultPort)
hostPort
- a String value containing the host and port formatted as 'host[port]'.defaultPort
- an Integer value indicating the default port to use if the port is unspecified
in the host and port String value.ConnectionEndpoint(String, int)
public String getHost()
public int getPort()
public InetSocketAddress toInetSocketAddress()
ConnectionEndpoint
into an InetSocketAddress
representation.InetSocketAddress
representation of this ConnectionEndpoint
.InetSocketAddress
,
getHost()
,
getPort()
protected Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public int compareTo(ConnectionEndpoint connectionEndpoint)
compareTo
in interface Comparable<ConnectionEndpoint>
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.