Class PeerEndpoint

java.lang.Object
org.drasyl.node.PeerEndpoint

public abstract class PeerEndpoint 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 Details

    • PeerEndpoint

      public PeerEndpoint()
  • Method Details

    • 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
    • getIdentityPublicKey

      @NonNull public abstract IdentityPublicKey getIdentityPublicKey()
      Returns the IdentityPublicKey of this Endpoint.
      Returns:
      The public key of this endpoint.
    • getNetworkId

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

      public InetSocketAddress toInetSocketAddress()
      Creates an unresolved socket address from getHost() and getPort().
      Throws:
      IllegalArgumentException - if the port parameter is outside the range of valid port values, or if the hostname parameter is null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static PeerEndpoint 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 PeerEndpoint 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 PeerEndpoint 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
    • of

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