Package org.drasyl.peer
Class Endpoint
- java.lang.Object
-
- org.drasyl.peer.Endpoint
-
-
Constructor Summary
Constructors Constructor Description Endpoint()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
getHost()
Returns the hostname of this endpoint.abstract IdentityPublicKey
getIdentityPublicKey()
Returns theIdentityPublicKey
of thisEndpoint
.abstract Integer
getNetworkId()
Returns the network id of this endpoint.abstract int
getPort()
Returns the port of this endpoint.URI
getURI()
Returns anURI
representing thisEndpoint
.static Endpoint
of(String endpoint)
Converts aString
into anEndpoint
.static Endpoint
of(String host, int port, IdentityPublicKey publicKey)
Converts the givenhost
,port
, andpublicKey
into anEndpoint
.static Endpoint
of(String host, int port, IdentityPublicKey publicKey, Integer networkId)
Converts the givenhost
,port
,publicKey
, andnetworkId
into anEndpoint
.static Endpoint
of(URI endpoint)
Converts anURI
into anEndpoint
.InetSocketAddressWrapper
toInetSocketAddress()
String
toString()
-
-
-
Method Detail
-
getURI
public URI getURI()
Returns anURI
representing thisEndpoint
.- Returns:
- The
URI
representing thisEndpoint
. - Throws:
IllegalArgumentException
- If the createdURI
violates RFC 2396
-
getHost
@NonNull public abstract String getHost()
Returns the hostname of this endpoint.- Returns:
- The hostname of this endpoint.
-
getPort
@NonNull public abstract int getPort()
Returns the port of this endpoint.- Returns:
- The port of this endpoint
-
getIdentityPublicKey
@NonNull public abstract IdentityPublicKey getIdentityPublicKey()
Returns theIdentityPublicKey
of thisEndpoint
.- Returns:
- The public key of this endpoint.
-
getNetworkId
@Nullable public abstract Integer getNetworkId()
Returns the network id of this endpoint.- Returns:
- The network id of this endpoint
-
toInetSocketAddress
public InetSocketAddressWrapper toInetSocketAddress()
- Throws:
IllegalArgumentException
- if the port parameter is outside the range of valid port values, or if the hostname parameter isnull
.
-
of
public static Endpoint 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
public static Endpoint of(String host, int port, IdentityPublicKey publicKey)
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
public static Endpoint of(URI endpoint)
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
public static Endpoint of(String endpoint)
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
-
-