Interface Parameters

All Known Subinterfaces:
UriQuery, UriQueryWriteable

public interface Parameters
Parameters abstraction (used by any component that has named parameters with possible multiple values). This is a read-only access to the parameters.
  • Field Details

  • Method Details

    • builder

      static Parameters.Builder builder(String component)
      Creates a new Parameters.Builder of Parameters.
      Parameters:
      component - component these parameters represent (such as request headers)
      Returns:
      builder instance
    • empty

      static Parameters empty(String component)
      Create empty (named) parameters.
      Parameters:
      component - component of the parameters to correctly report errors
      Returns:
      new named parameters with no values
    • create

      static Parameters create(String component, Map<String,List<String>> params)
      Read only parameters based on a map.
      Parameters:
      component - component of the parameters to correctly report errors
      params - underlying map
      Returns:
      new named parameters with values based on the map
    • createSingleValueMap

      static Parameters createSingleValueMap(String component, Map<String,String> params)
      Read only parameters based on a map with just a single value.
      Parameters:
      component - component of the parameters to correctly report errors
      params - underlying map
      Returns:
      new named parameters with values based on the map
    • all

      Get all values.
      Parameters:
      name - name of the parameter
      Returns:
      all values as a list
      Throws:
      NoSuchElementException - in case the name is not present
    • all

      default List<String> all(String name, Supplier<List<String>> defaultValues)
      Get all values using a default value supplier if the parameter does not exist.
      Parameters:
      name - name of the parameter
      defaultValues - default values supplier to use if parameter is not present
      Returns:
      all values as a list
    • allValues

      List<Value<String>> allValues(String name) throws NoSuchElementException
      A list of values for the named parameter.
      Parameters:
      name - name of the parameter
      Returns:
      list of parameter values, mappable to other types
      Throws:
      NoSuchElementException - in case the name is not present in these parameters
    • allValues

      default List<Value<String>> allValues(String name, Supplier<List<Value<String>>> defaultValues)
      Get all values using a default value supplier if the parameter does not exist.
      Parameters:
      name - name of the parameter
      defaultValues - default values supplier to use if parameter is not present
      Returns:
      all values as a list
    • get

      Get the first value.
      Parameters:
      name - name of the parameter
      Returns:
      first value
      Throws:
      NoSuchElementException - in case the name is not present
    • first

      OptionalValue<String> first(String name)
      Get the first value as an optional. Managing optionals has performance impact. If performance is of issue, use contains(String) and get(String) instead.
      Parameters:
      name - name of the parameter
      Returns:
      first value or empty optional
    • contains

      boolean contains(String name)
      Whether these parameters contain the provided name.
      Parameters:
      name - name of the parameter
      Returns:
      true if the parameter is present, false otherwise
    • isEmpty

      default boolean isEmpty()
      Whether these parameters are empty.
      Returns:
      true if there is no parameter defined
    • size

      int size()
      Number of parameter names in these parameters.
      Returns:
      size of these parameters
    • names

      Set<String> names()
      Set of parameter names.
      Returns:
      names available in these parameters
    • component

      String component()
      Name of the component of these parameters.
      Returns:
      component name
    • toMap

      default Map<String,List<String>> toMap()
      Get a map representation of these parameters. Changes to the map will not be propagated to this instance.
      Returns:
      a new map