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 TypeMethodDescriptionintCompares thisEndpointto another object, which must be aEndpoint.booleangetHost()Returns the host component of this endpoint.intgetPort()Returns the port of this endpoint.Returns theCompressedPublicKeyof thisEndpoint.getURI()Returns theURIof thisEndpoint.inthashCode()booleanReturnstrueif endpoint uses WebSocket Secure protocol.static EndpointConverts aStringto aEndpoint.static Endpointof(String uri, CompressedPublicKey publicKey) static EndpointConverts anURIintoEndpoint.static Endpointof(URI uri, CompressedPublicKey publicKey) toString()
-
Method Details
-
getURI
Returns theURIof thisEndpoint.- Returns:
- a
URIcontained in thisEndpoint
-
getPublicKey
Returns theCompressedPublicKeyof 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
nullif the host is undefined
-
getPort
public int getPort()Returns the port of this endpoint.- Returns:
- The port of this endpoint
-
isSecureEndpoint
public boolean isSecureEndpoint()Returnstrueif endpoint uses WebSocket Secure protocol. Otherwisefalse.- Returns:
trueif endpoint uses WebSocket Secure protocol. Otherwisefalse
-
compareTo
Compares thisEndpointto another object, which must be aEndpoint.- Specified by:
compareToin interfaceComparable<Endpoint>- Parameters:
that- The object to which thisEndpointis to be compared- Returns:
- A negative integer, zero, or a positive integer as this
Endpointis less than, equal to, or greater than the givenEndpoint
-
of
- Parameters:
uri- uri component of the endpointpublicKey- public key component of the endpoint- Returns:
Endpointconverted fromuriandpublicKey- Throws:
NullPointerException- ifuriisnullIllegalArgumentException- ifuriandpublicKeycreates an invalidEndpoint
-
of
- Parameters:
uri- uri component of the endpointpublicKey- public key component of the endpoint- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifuriisnullIllegalArgumentException- ifuriandpublicKeycreates an invalidEndpointor violates RFC 2396
-
of
Converts anURIintoEndpoint.- Parameters:
endpoint- a drasyl node endpoint represented asURI- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullIllegalArgumentException- ifendpointis an invalidEndpoint
-
of
Converts aStringto aEndpoint.- Parameters:
endpoint- a drasyl node endpoint represented asURI- Returns:
Endpointconverted fromendpoint- Throws:
NullPointerException- ifendpointisnullIllegalArgumentException- ifendpointis an invalidEndpointor violates RFC 2396
-