Package org.drasyl.peer
Class Endpoint
java.lang.Object
org.drasyl.peer.Endpoint
- All Implemented Interfaces:
Comparable<Endpoint>
Represents an endpoint of a drasyl node. This is a
URI
that must use the WebSocket
(Secure) protocol.
This is an immutable object.
-
Method Summary
Modifier and TypeMethodDescriptionint
Compares thisEndpoint
to another object, which must be aEndpoint
.boolean
getHost()
Returns the host component of this endpoint.int
getPort()
Returns the port of this endpoint.Returns theCompressedPublicKey
of thisEndpoint
.getURI()
Returns theURI
of thisEndpoint
.int
hashCode()
boolean
Returnstrue
if endpoint uses WebSocket Secure protocol.static Endpoint
Converts aString
to aEndpoint
.static Endpoint
of
(String uri, CompressedPublicKey publicKey) static Endpoint
Converts anURI
intoEndpoint
.static Endpoint
of
(URI uri, CompressedPublicKey publicKey) toString()
-
Method Details
-
getURI
Returns theURI
of thisEndpoint
.- Returns:
- a
URI
contained in thisEndpoint
-
getPublicKey
Returns theCompressedPublicKey
of thisEndpoint
.- Returns:
- a
CompressedPublicKey
-
equals
-
hashCode
public int hashCode() -
toString
-
getHost
Returns the host component of this endpoint.- Returns:
- The host component of this URI, or
null
if the host is undefined
-
getPort
public int getPort()Returns the port of this endpoint.- Returns:
- The port of this endpoint
-
isSecureEndpoint
public boolean isSecureEndpoint()Returnstrue
if endpoint uses WebSocket Secure protocol. Otherwisefalse
.- Returns:
true
if endpoint uses WebSocket Secure protocol. Otherwisefalse
-
compareTo
Compares thisEndpoint
to another object, which must be aEndpoint
.- Specified by:
compareTo
in interfaceComparable<Endpoint>
- Parameters:
that
- The object to which thisEndpoint
is to be compared- Returns:
- A negative integer, zero, or a positive integer as this
Endpoint
is less than, equal to, or greater than the givenEndpoint
-
of
- Parameters:
uri
- uri component of the endpointpublicKey
- public key component of the endpoint- Returns:
Endpoint
converted fromuri
andpublicKey
- Throws:
NullPointerException
- ifuri
isnull
IllegalArgumentException
- ifuri
andpublicKey
creates an invalidEndpoint
-
of
- Parameters:
uri
- uri component of the endpointpublicKey
- public key component of the endpoint- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifuri
isnull
IllegalArgumentException
- ifuri
andpublicKey
creates an invalidEndpoint
or violates RFC 2396
-
of
Converts anURI
intoEndpoint
.- Parameters:
endpoint
- a drasyl node endpoint represented asURI
- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
IllegalArgumentException
- ifendpoint
is an invalidEndpoint
-
of
Converts aString
to aEndpoint
.- Parameters:
endpoint
- a drasyl node endpoint represented asURI
- Returns:
Endpoint
converted fromendpoint
- Throws:
NullPointerException
- ifendpoint
isnull
IllegalArgumentException
- ifendpoint
is an invalidEndpoint
or violates RFC 2396
-