Interface AbsoluteUrl

All Superinterfaces:
AbsoluteUri, Normalisable<AbsoluteUri>, org.wiremock.stringparser.ParsedString, Uri, Url, UrlWithAuthority
All Known Subinterfaces:
BaseUrl, Origin, ServersideAbsoluteUrl
All Known Implementing Classes:
BaseUrlValue

public non-sealed interface AbsoluteUrl extends AbsoluteUri, UrlWithAuthority
Represents a Uniform Resource Locator (URL) as defined in RFC 3986. The name AbsoluteUrl is used in preference to Url because it is more familiar to developers, who habitually think of both relative and complete URL references as URLs and use absolute URL to mean the latter. Note that this is not an absolute URL in the RFC 3986 sense of a complete URI with no fragment.

An AbsoluteUrl consists of a scheme, authority (host and optional port and user info), path, optional query, and optional fragment. AbsoluteUrls always have both a scheme and an authority component.

Implementations must be immutable and thread-safe.

See Also:
  • Method Details

    • getAuthority

      Authority getAuthority()
      Returns the authority component of this URL.

      URLs always have an authority component (unlike relative references and URNs).

      Specified by:
      getAuthority in interface Uri
      Specified by:
      getAuthority in interface UrlWithAuthority
      Returns:
      the authority component, never null
    • isRelative

      default boolean isRelative()
      Description copied from interface: Uri
      Returns true if this is a relative reference (has no scheme).
      Specified by:
      isRelative in interface AbsoluteUri
      Specified by:
      isRelative in interface Uri
      Returns:
      true if this is a relative reference
    • isAbsoluteUrl

      default boolean isAbsoluteUrl()
      Description copied from interface: Uri
      Returns true if this is an absolute URL (has a scheme and authority).
      Specified by:
      isAbsoluteUrl in interface Uri
      Returns:
      true if this is an absolute URL
    • isOpaqueUri

      default boolean isOpaqueUri()
      Description copied from interface: Uri
      Returns true if this is an Opaque URI (has a scheme but no authority).
      Specified by:
      isOpaqueUri in interface Uri
      Returns:
      true if this is an Opaque URI
    • getHost

      default Host getHost()
      Description copied from interface: Uri
      Returns the host component from the authority, or null if there is no authority.
      Specified by:
      getHost in interface Uri
      Returns:
      the host component, or null if absent
    • getOrigin

      default Origin getOrigin()
      Returns the origin of this URL, consisting of the scheme, host, and port.
      Returns:
      the origin
    • getServersideAbsoluteUrl

      default ServersideAbsoluteUrl getServersideAbsoluteUrl()
      Returns the serverside absolute URL of this URL, this URL without a fragment
      Returns:
      the origin
    • toBaseUrl

      default BaseUrl toBaseUrl()
      Returns this URL as a base URL, by removing the query and fragment and ensuring the path is either empty or ends with /
      Returns:
      the origin
    • getSchemeRelativeUrl

      default SchemeRelativeUrl getSchemeRelativeUrl()
      Specified by:
      getSchemeRelativeUrl in interface UrlWithAuthority
    • normalise

      AbsoluteUrl normalise()
      Returns a normalised form of this URL.
      Specified by:
      normalise in interface AbsoluteUri
      Specified by:
      normalise in interface Normalisable<AbsoluteUri>
      Returns:
      a normalised URL
    • resolve

      default AbsoluteUrl resolve(String other) throws IllegalUrl
      Resolves the given string as a URI reference against this URL.
      Parameters:
      other - the URL to resolve
      Returns:
      the resolved absolute URL
      Throws:
      IllegalUrl - if the other is not a valid URL
    • resolve

      default AbsoluteUrl resolve(Path other)
      Resolves the given path against this URL.
      Specified by:
      resolve in interface AbsoluteUri
      Parameters:
      other - the path to resolve
      Returns:
      the URL with the resolved path
    • resolve

      default AbsoluteUrl resolve(Url other)
      Resolves the given URL reference against this URL.
      Parameters:
      other - the URL reference to resolve
      Returns:
      the resolved URL
    • thaw

      default AbsoluteUrl.Transformer thaw()
      Creates a builder initialized with the values from this URL.
      Specified by:
      thaw in interface AbsoluteUri
      Specified by:
      thaw in interface Url
      Returns:
      a builder
    • transform

      default AbsoluteUrl transform(Consumer<Uri.Transformer<?>> mutator)
      Transforms this URL by applying modifications via a transformer.
      Specified by:
      transform in interface AbsoluteUri
      Specified by:
      transform in interface Url
      Parameters:
      mutator - a function that modifies the transformer
      Returns:
      the transformed URL
    • parse

      static AbsoluteUrl parse(String url) throws IllegalAbsoluteUrl
      Parses a string into a URL.
      Parameters:
      url - the string to parse
      Returns:
      the parsed URL
      Throws:
      IllegalAbsoluteUrl - if the string is not a valid URL
    • builder

      static AbsoluteUrl.Builder builder(Scheme scheme, Authority authority)
      Creates a new builder with the given scheme and authority.
      Parameters:
      scheme - the scheme
      authority - the authority
      Returns:
      a new builder
    • builder

      static AbsoluteUrl.Builder builder(AbsoluteUrl url)
      Creates a builder initialized with the values from the given URL.
      Parameters:
      url - the URL to copy values from
      Returns:
      a new builder