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 a URI that must use the WebSocket (Secure) protocol.

This is an immutable object.

  • Method Details

    • getURI

      public URI getURI()
      Returns the URI of this Endpoint.
      Returns:
      a URI contained in this Endpoint
    • getPublicKey

      public CompressedPublicKey getPublicKey()
      Returns the CompressedPublicKey of this Endpoint.
      Returns:
      a CompressedPublicKey
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object
    • 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()
      Returns true if endpoint uses WebSocket Secure protocol. Otherwise false.
      Returns:
      true if endpoint uses WebSocket Secure protocol. Otherwise false
    • compareTo

      public int compareTo(Endpoint that)
      Compares this Endpoint to another object, which must be a Endpoint.
      Specified by:
      compareTo in interface Comparable<Endpoint>
      Parameters:
      that - The object to which this Endpoint 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 given Endpoint
    • of

      public static Endpoint of(URI uri, CompressedPublicKey publicKey)
      Converts an URI and CompressedPublicKey into Endpoint.
      Parameters:
      uri - uri component of the endpoint
      publicKey - public key component of the endpoint
      Returns:
      Endpoint converted from uri and publicKey
      Throws:
      NullPointerException - if uri is null
      IllegalArgumentException - if uri and publicKey creates an invalid Endpoint
    • of

      public static Endpoint of(String uri, CompressedPublicKey publicKey)
      Converts an String and CompressedPublicKey into Endpoint.
      Parameters:
      uri - uri component of the endpoint
      publicKey - public key component of the endpoint
      Returns:
      Endpoint converted from endpoint
      Throws:
      NullPointerException - if uri is null
      IllegalArgumentException - if uri and publicKey creates an invalid Endpoint or violates RFC 2396
    • of

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

      public static Endpoint of(String endpoint)
      Converts a String to a Endpoint.
      Parameters:
      endpoint - a drasyl node endpoint represented as URI
      Returns:
      Endpoint converted from endpoint
      Throws:
      NullPointerException - if endpoint is null
      IllegalArgumentException - if endpoint is an invalid Endpoint or violates RFC 2396