Package org.drasyl.node
Class PeerEndpoint
java.lang.Object
org.drasyl.node.PeerEndpoint
Represents an endpoint of a drasyl node. This is a
URI
that must use the WebSocket
(Secure) protocol.
This is an immutable object.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
getHost()
Returns the hostname of this endpoint.abstract IdentityPublicKey
Returns theIdentityPublicKey
of thisEndpoint
.abstract Integer
Returns the network id of this endpoint.abstract int
getPort()
Returns the port of this endpoint.getURI()
Returns anURI
representing thisEndpoint
.static PeerEndpoint
Converts aString
into anEndpoint
.static PeerEndpoint
of
(String host, int port, IdentityPublicKey publicKey) Converts the givenhost
,port
, andpublicKey
into anEndpoint
.static PeerEndpoint
of
(String host, int port, IdentityPublicKey publicKey, Integer networkId) Converts the givenhost
,port
,publicKey
, andnetworkId
into anEndpoint
.static PeerEndpoint
Converts anURI
into anEndpoint
.toString()
-
Constructor Details
-
PeerEndpoint
public PeerEndpoint()
-
-
Method Details
-
getURI
Returns anURI
representing thisEndpoint
.- Returns:
- The
URI
representing thisEndpoint
. - Throws:
IllegalArgumentException
- If the createdURI
violates RFC 2396
-
getHost
Returns the hostname of this endpoint.- Returns:
- The hostname of this endpoint.
-
getPort
Returns the port of this endpoint.- Returns:
- The port of this endpoint
-
getIdentityPublicKey
Returns theIdentityPublicKey
of thisEndpoint
.- Returns:
- The public key of this endpoint.
-
getNetworkId
Returns the network id of this endpoint.- Returns:
- The network id of this endpoint
-
toInetSocketAddress
- Throws:
IllegalArgumentException
- if the port parameter is outside the range of valid port values, or if the hostname parameter isnull
.
-
toString
-
of
public static PeerEndpoint of(String host, int port, IdentityPublicKey publicKey, Integer networkId) Converts the givenhost
,port
,publicKey
, andnetworkId
into anEndpoint
.- Parameters:
host
- the hostname part of the endpointport
- the port number of the endpointpublicKey
- the public key of the endpointnetworkId
- the network id of the endpoint- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
or contains no public keyIllegalArgumentException
- ifhost
,port
, andpublicKey
creates an invalidEndpoint
-
of
Converts the givenhost
,port
, andpublicKey
into anEndpoint
.- Parameters:
host
- the hostname part of the endpointport
- the port number of the endpointpublicKey
- the public key of the endpoint- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
or contains no public keyIllegalArgumentException
- ifhost
,port
, andpublicKey
creates an invalidEndpoint
-
of
Converts anURI
into anEndpoint
.- Parameters:
endpoint
- a drasyl node endpoint represented asURI
- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
or contains no public keyIllegalArgumentException
- ifendpoint
creates an invalidEndpoint
-
of
Converts aString
into anEndpoint
.- Parameters:
endpoint
- a drasyl node endpoint represented asURI
- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
IllegalArgumentException
- ifendpoint
creates an invalidEndpoint
-