Package org.drasyl.peer
Class Endpoint
- java.lang.Object
-
- org.drasyl.peer.Endpoint
-
- All Implemented Interfaces:
Comparable<Endpoint>
public class Endpoint extends Object implements Comparable<Endpoint>
Represents an endpoint of a drasyl node. This is aURI
that must use the WebSocket (Secure) protocol.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Endpoint that)
Compares thisEndpoint
to another object, which must be aEndpoint
.boolean
equals(Object o)
String
getHost()
Returns the host component of this endpoint.int
getPort()
Returns the port of this endpoint.CompressedPublicKey
getPublicKey()
Returns theCompressedPublicKey
of thisEndpoint
.URI
getURI()
Returns theURI
of thisEndpoint
.int
hashCode()
boolean
isSecureEndpoint()
Returnstrue
if endpoint uses WebSocket Secure protocol.static Endpoint
of(String endpoint)
Converts aString
to aEndpoint
.static Endpoint
of(String uri, CompressedPublicKey publicKey)
static Endpoint
of(URI endpoint)
Converts anURI
intoEndpoint
.static Endpoint
of(URI uri, CompressedPublicKey publicKey)
String
toString()
-
-
-
Method Detail
-
getURI
public URI getURI()
Returns theURI
of thisEndpoint
.- Returns:
- a
URI
contained in thisEndpoint
-
getPublicKey
public CompressedPublicKey getPublicKey()
Returns theCompressedPublicKey
of thisEndpoint
.- Returns:
- a
CompressedPublicKey
if thisEndpoint
contains a public key. Otherwisenull
-
getHost
public String 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
public int compareTo(Endpoint that)
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
public static Endpoint of(URI uri, CompressedPublicKey publicKey)
- 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
public static Endpoint of(String uri, CompressedPublicKey publicKey)
- 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
public static Endpoint of(URI endpoint)
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
public static Endpoint of(String endpoint)
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
-
-