Interface UriBuilder


public interface UriBuilder
Helper class for building URIs and handle encoding correctly.
Since:
1.0.2
Author:
graemerocher
  • Method Details

    • fragment

      @NonNull UriBuilder fragment(@Nullable String fragment)
      Sets the URI fragment.
      Parameters:
      fragment - The fragument
      Returns:
      This builder
    • scheme

      Sets the URI scheme.
      Parameters:
      scheme - The scheme
      Returns:
      This builder
    • userInfo

      @NonNull UriBuilder userInfo(@Nullable String userInfo)
      Sets the URI user info.
      Parameters:
      userInfo - The use info
      Returns:
      This builder
    • host

      Sets the URI host.
      Parameters:
      host - The host to use
      Returns:
      This builder
    • port

      @NonNull UriBuilder port(int port)
      Sets the URI port.
      Parameters:
      port - The port to use
      Returns:
      This builder
    • path

      Appends the given path to the existing path correctly handling '/'. If path is null it is simply ignored.
      Parameters:
      path - The path
      Returns:
      This builder
    • replacePath

      @NonNull UriBuilder replacePath(@Nullable String path)
      Replaces the existing path if any. If path is null it is simply ignored.
      Parameters:
      path - The path
      Returns:
      This builder
    • queryParam

      @NonNull UriBuilder queryParam(String name, Object... values)
      Adds a query parameter for the give name and values. The values will be URI encoded. If either name or values are null the value will be ignored.
      Parameters:
      name - The name
      values - The values
      Returns:
      This builder
    • replaceQueryParam

      @NonNull UriBuilder replaceQueryParam(String name, Object... values)
      Adds a query parameter for the give name and values. The values will be URI encoded. If either name or values are null the value will be ignored.
      Parameters:
      name - The name
      values - The values
      Returns:
      This builder
    • build

      @NonNull URI build()
      The constructed URI.
      Returns:
      Build the URI
      Throws:
      UriSyntaxException - if the URI to be constructed is invalid
    • expand

      @NonNull URI expand(Map<String,? super Object> values)
      Expands the URI if it is a template, using the given values.
      Parameters:
      values - Expands the URI with the given values.
      Returns:
      Build the URI
    • of

      @NonNull static UriBuilder of(@NonNull URI uri)
      Create a UriBuilder with the given base URI as a starting point.
      Parameters:
      uri - The URI
      Returns:
      The builder
    • of

      Create a UriBuilder with the given base URI as a starting point.
      Parameters:
      uri - The URI
      Returns:
      The builder