Interface Url

All Superinterfaces:
org.wiremock.stringparser.ParsedString, Uri
All Known Subinterfaces:
AbsoluteUrl, BaseUrl, Origin, PathAndQuery, RelativeUrl, SchemeRelativeUrl, ServersideAbsoluteUrl, UrlWithAuthority
All Known Implementing Classes:
BaseUrlValue

public sealed interface Url extends Uri permits RelativeUrl, UrlWithAuthority
Represents a URL reference, which is the subset of URI references that are not full (absolute) URIs without an authority - what we call OpaqueUris. The name Url is used in preference to UrlReference because it is more familiar to developers, who habitually think of both relative and complete URL references as URLs.

An Url is either an AbsoluteUrl or an RelativeUrl. An AbsoluteUrl is guaranteed to resolve to an AbsoluteUrl if resolved against an Url, whereas it may resolve to an OpaqueUri if resolved against an Uri.

Implementations must be immutable and thread-safe.

See Also:
  • Method Details

    • getPathAndQuery

      default PathAndQuery getPathAndQuery()
      Returns the path and query components combined.
      Returns:
      the path and query
    • thaw

      default Url.Transformer<?> thaw()
      Creates a transformer initialized with the values from this URL.
      Returns:
      a transformer
    • transform

      default Url transform(Consumer<Uri.Transformer<?>> mutator) throws IllegalUri
      Convenience method for transforming a Url
      Parameters:
      mutator - a function to mutate the transformer
      Returns:
      the transformed Url
      Throws:
      IllegalUrl - if scheme is set and Authority is not set
      IllegalUri
    • builder

      static Url.Builder builder()
      Creates a new builder
      Returns:
      a new builder
    • builder

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

      static Url parse(String url) throws IllegalUri
      Parses a string into a URI reference.
      Parameters:
      url - the string to parse
      Returns:
      the parsed URI reference
      Throws:
      IllegalUri - if the string is not a valid URI reference