Class Endpoint


  • public abstract 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.

    • Constructor Detail

      • Endpoint

        public Endpoint()
    • 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

        @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
      • getNetworkId

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

        public static Endpoint of​(String host,
                                  int port,
                                  IdentityPublicKey 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,
                                  IdentityPublicKey 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