Interface HostAndPort

All Superinterfaces:
Authority, Normalisable<Authority>, org.wiremock.stringparser.ParsedString

public interface HostAndPort extends Authority
Represents an authority component consisting of only a host and optional port, with no user info.

This is a specialized form of Authority that is guaranteed to have no user information. It is commonly used for origins and server identification.

Implementations must be immutable and thread-safe.

  • Field Details

  • Method Details

    • of

      static HostAndPort of(Host host)
      Creates a host and port from a host.
      Parameters:
      host - the host
      Returns:
      the host and port
    • of

      static HostAndPort of(Host host, @Nullable Port port)
      Creates a host and port from a host and optional port.
      Parameters:
      host - the host
      port - the port, or null
      Returns:
      the host and port
    • parse

      static HostAndPort parse(String hostAndPortStr) throws IllegalAuthority
      Parses a string into a host and port.
      Parameters:
      hostAndPortStr - the string to parse
      Returns:
      the parsed host and port
      Throws:
      IllegalHostAndPort - if the string is not a valid host and port
      IllegalAuthority - if the string is not a valid authority
    • getUserInfo

      @Deprecated default @Nullable UserInfo getUserInfo()
      Deprecated.
      This always returns null so you have no reason to ever call it
      Implementations must ALWAYS return null
      Specified by:
      getUserInfo in interface Authority
      Returns:
      null
    • getHostAndPort

      @Deprecated default HostAndPort getHostAndPort()
      Deprecated.
      This always returns this so you have no reason to ever call it
      Implementations must ALWAYS return this
      Specified by:
      getHostAndPort in interface Authority
      Returns:
      this
    • withPort

      HostAndPort withPort(@Nullable Port port)
      Returns a new host and port with the specified port.
      Specified by:
      withPort in interface Authority
      Parameters:
      port - the port to set, or null to remove it
      Returns:
      a new host and port with the updated port
    • normalise

      HostAndPort normalise()
      Returns a normalized form of this host and port.
      Specified by:
      normalise in interface Normalisable<Authority>
      Returns:
      a normalized host and port
    • normalise

      HostAndPort normalise(Scheme canonicalScheme)
      Returns a normalized form of this host and port using scheme-specific normalization rules.
      Specified by:
      normalise in interface Authority
      Parameters:
      canonicalScheme - the canonical scheme to use for normalization
      Returns:
      a normalized host and port