Package nbbrd.io.http

Class URLQueryBuilder

java.lang.Object
nbbrd.io.http.URLQueryBuilder

public final class URLQueryBuilder extends Object
Author:
Philippe Charles
  • Constructor Details

    • URLQueryBuilder

      public URLQueryBuilder()
  • Method Details

    • of

      @NonNull public static @NonNull URLQueryBuilder of(@NonNull @NonNull URL endPoint)
    • trailingSlash

      @NonNull public @NonNull URLQueryBuilder trailingSlash(boolean trailingSlash)
      Appends a trailing slash to the final URL.
      Parameters:
      trailingSlash - specify if a trailing slash is required
      Returns:
      this builder
      See Also:
    • path

      @NonNull public @NonNull URLQueryBuilder path(@NonNull @NonNull String path)
      Appends the specified path to the current URL.
      Parameters:
      path - a non-null path
      Returns:
      this builder
      Throws:
      NullPointerException - if path is null
    • path

      @NonNull public @NonNull URLQueryBuilder path(@NonNull @NonNull List<String> path)
      Appends the specified path to the current URL.
      Parameters:
      path - a non-null path
      Returns:
      this builder
      Throws:
      NullPointerException - if path is null
    • param

      @NonNull public @NonNull URLQueryBuilder param(@NonNull @NonNull String key, @NonNull @NonNull String value)
      Appends the specified parameter to the current URL.
      Parameters:
      key - a non-null key
      value - a non-null value
      Returns:
      this builder
      Throws:
      NullPointerException - if key or value is null
    • param

      @NonNull public @NonNull URLQueryBuilder param(@NonNull @NonNull String key)
      Appends the specified parameter to the current URL.
      Parameters:
      key - a non-null key
      Returns:
      this builder
      Throws:
      NullPointerException - if key or value is null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • build

      @NonNull public @NonNull URL build() throws MalformedURLException
      Creates a new URL using the specified path and parameters.
      Returns:
      a new URL
      Throws:
      MalformedURLException - if no protocol is specified, or an unknown protocol is found, or spec is null, or the parsed URL fails to comply with the specific syntax of the associated protocol.