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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetHost()Returns the hostname of this endpoint.abstract IdentityPublicKeyReturns theIdentityPublicKeyof thisEndpoint.abstract IntegerReturns the network id of this endpoint.abstract intgetPort()Returns the port of this endpoint.getURI()Returns anURIrepresenting thisEndpoint.static PeerEndpointConverts aStringinto anEndpoint.static PeerEndpointof(String host, int port, IdentityPublicKey publicKey) Converts the givenhost,port, andpublicKeyinto anEndpoint.static PeerEndpointof(String host, int port, IdentityPublicKey publicKey, Integer networkId) Converts the givenhost,port,publicKey, andnetworkIdinto anEndpoint.static PeerEndpointConverts anURIinto anEndpoint.toString()
-
Constructor Details
-
PeerEndpoint
public PeerEndpoint()
-
-
Method Details
-
getURI
Returns anURIrepresenting thisEndpoint.- Returns:
- The
URIrepresenting thisEndpoint. - Throws:
IllegalArgumentException- If the createdURIviolates 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 theIdentityPublicKeyof 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, andnetworkIdinto 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:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullor contains no public keyIllegalArgumentException- ifhost,port, andpublicKeycreates an invalidEndpoint
-
of
Converts the givenhost,port, andpublicKeyinto anEndpoint.- Parameters:
host- the hostname part of the endpointport- the port number of the endpointpublicKey- the public key of the endpoint- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullor contains no public keyIllegalArgumentException- ifhost,port, andpublicKeycreates an invalidEndpoint
-
of
Converts anURIinto anEndpoint.- Parameters:
endpoint- a drasyl node endpoint represented asURI- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullor contains no public keyIllegalArgumentException- ifendpointcreates an invalidEndpoint
-
of
Converts aStringinto anEndpoint.- Parameters:
endpoint- a drasyl node endpoint represented asURI- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullIllegalArgumentException- ifendpointcreates an invalidEndpoint
-