Class Endpoint


  • public class Endpoint
    extends Object
    Represents an endpoint of a drasyl node. This is a URI that must use the WebSocket (Secure) protocol.

    This is an immutable object.

    • Method Detail

      • getURI

        public URI getURI()
        Returns an URI representing this Endpoint.
        Returns:
        The URI representing this Endpoint.
        Throws:
        IllegalArgumentException - If the created URI violates RFC 2396
      • getHost

        public String getHost()
        Returns the hostname of this endpoint.
        Returns:
        The hostname of this endpoint.
      • getPort

        public int getPort()
        Returns the port of this endpoint.
        Returns:
        The port of this endpoint
      • getNetworkId

        public Integer getNetworkId()
        Returns the network id of this endpoint.
        Returns:
        The network id of this endpoint
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • of

        public static Endpoint of​(String host,
                                  int port,
                                  CompressedPublicKey publicKey,
                                  Integer networkId)
        Converts the given host, port, publicKey, and networkId into an Endpoint.
        Parameters:
        host - the hostname part of the endpoint
        port - the port number of the endpoint
        publicKey - the public key of the endpoint
        networkId - the network id of the endpoint
        Returns:
        Endpoint converted from endpoint
        Throws:
        NullPointerException - if endpoint is null or contains no public key
        IllegalArgumentException - if host, port, and publicKey creates an invalid Endpoint
      • of

        public static Endpoint of​(String host,
                                  int port,
                                  CompressedPublicKey publicKey)
        Converts the given host, port, and publicKey into an Endpoint.
        Parameters:
        host - the hostname part of the endpoint
        port - the port number of the endpoint
        publicKey - the public key of the endpoint
        Returns:
        Endpoint converted from endpoint
        Throws:
        NullPointerException - if endpoint is null or contains no public key
        IllegalArgumentException - if host, port, and publicKey creates an invalid Endpoint
      • of

        public static Endpoint of​(URI endpoint)
        Converts an URI into an Endpoint.
        Parameters:
        endpoint - a drasyl node endpoint represented as URI
        Returns:
        Endpoint converted from endpoint
        Throws:
        NullPointerException - if endpoint is null or contains no public key
        IllegalArgumentException - if endpoint creates an invalid Endpoint