Class UrlContent

java.lang.Object
com.persequor.extension.frontend.UrlContent

public class UrlContent extends Object
UrlContent is a data structure containing the path variables and query parameters.

All of its methods are chainable, e.g.

UrlContent urlContent = new UrlContent().variable(1, "value1").parameter("param1", "value1");

  • Constructor Details

    • UrlContent

      public UrlContent()
  • Method Details

    • variable

      public UrlContent variable(int order, String value)
      Adds a path variable to the UrlContent, e.g. /path/{variable1}

      The order of the path variable is used to sort the path variables in the url string.

      When sorting negative order values are sorted before positive order values, e.g. -1, 1, 2, 10

      Parameters:
      order - the order of the path variable, e.g. 1 if it's the first path variable in the url string
      value - the value of the path variable, e.g. variable1
      Returns:
      the UrlContent object, for chaining
    • parameter

      public UrlContent parameter(String name, String value)
      Adds a query parameter to the UrlContent, e.g. /path?param1=value1

      See parameter(String, List) for more information

      Parameters:
      name - the name of the query parameter, e.g. param1
      value - the value of the query parameter, e.g. value1
      Returns:
      the UrlContent object, for chaining
    • parameter

      public UrlContent parameter(String name, ZonedDateTime value)
      Adds ZonedDateTime query parameter to the UrlContent, e.g. /path?param1=value1

      The value is formatted using DateTimeFormatter.ISO_DATE_TIME, which is the default format for ZonedDateTime when using Saga to send and receive ZonedDateTime objects for the frontend.

      See parameter(String, List) for more information on how the value is encoded

      Parameters:
      name - the name of the query parameter, e.g. param1
      value - the value of the query parameter, e.g. ZonedDateTime.now()
      Returns:
      the UrlContent object, for chaining
    • parameter

      public UrlContent parameter(String name, Instant value)
      Adds Instant query parameter to the UrlContent, e.g. /path?param1=value1

      The value is formatted using Instant.toEpochMilli(), which is the default format for Instant when using Saga to send and receive Instant objects for the frontend.

      See parameter(String, List) for more information on how the value is encoded

      Parameters:
      name - the name of the query parameter, e.g. param1
      value - the value of the query parameter, e.g. Instant.now()
      Returns:
      the UrlContent object, for chaining
    • parameter

      public UrlContent parameter(String name, List<String> value)
      Adds a query parameter to the UrlContent, e.g. /path?param1=value1,value2

      The values are individually url encoded, using UTF-8 as the encoding charset

      If the parameter name has been used before, the new values overwrite the old values

      Parameters:
      name - the name of the query parameter, e.g. param1
      value - the values of the query parameter, e.g. [value1, value2]
      Returns:
      the UrlContent object, for chaining
    • getVariables

      public List<PathVariable> getVariables()
      Gets the path variables in the UrlContent
      Returns:
      the path variables
    • setVariables

      public UrlContent setVariables(List<PathVariable> variables)
      Overrides the path variables in the UrlContent

      Should be used with caution

      Parameters:
      variables - the new path variables
      Returns:
      the UrlContent object, for chaining
    • getParameters

      public Map<String,List<String>> getParameters()
      Gets the query parameters in the UrlContent
      Returns:
      the query parameters
    • setParameters

      public UrlContent setParameters(Map<String,List<String>> parameters)
      Overrides the query parameters in the UrlContent

      Should be used with caution

      Parameters:
      parameters - the new query parameters
      Returns:
      the UrlContent object, for chaining