Interface QueryParamsBuilder

All Superinterfaces:
Iterable<Map.Entry<String,​String>>

public interface QueryParamsBuilder
Builds a QueryParams.
See Also:
QueryParams.builder(), QueryParams.toBuilder()
  • Method Details

    • build

      QueryParams build()
      Returns a newly created QueryParams with the entries in this builder.
    • sizeHint

      QueryParamsBuilder sizeHint​(int sizeHint)
      Specifies the hint about the number of parameters which may improve the memory efficiency and performance of the underlying data structure.
      Returns:
      this
      Throws:
      IllegalStateException - if the hint was specified too late after the underlying data structure has been fully initialized.
    • getAndRemove

      @Nullable String getAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the first parameter value or null if there is no such parameter
    • getAndRemove

      String getAndRemove​(String name, String defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the first parameter value or defaultValue if there is no such parameter
    • getAllAndRemove

      List<String> getAllAndRemove​(String name)
      Removes all the parameters with the specified name and returns the removed parameter values.
      Parameters:
      name - the parameter name
      Returns:
      a List of parameter values or an empty List if no values are found.
    • getIntAndRemove

      @Nullable Integer getIntAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the int value of the first value in insertion order or null if there is no such value or it can't be converted into int.
    • getIntAndRemove

      int getIntAndRemove​(String name, int defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the int value of the first value in insertion order or defaultValue if there is no such value or it can't be converted into int.
    • getLongAndRemove

      @Nullable Long getLongAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the long value of the first value in insertion order or null if there is no such value or it can't be converted into long.
    • getLongAndRemove

      long getLongAndRemove​(String name, long defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the long value of the first value in insertion order or defaultValue if there is no such value or it can't be converted into long.
    • getFloatAndRemove

      @Nullable Float getFloatAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the float value of the first value in insertion order or null if there is no such value or it can't be converted into float.
    • getFloatAndRemove

      float getFloatAndRemove​(String name, float defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the float value of the first value in insertion order or defaultValue if there is no such value or it can't be converted into float.
    • getDoubleAndRemove

      @Nullable Double getDoubleAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the double value of the first value in insertion order or null if there is no such value or it can't be converted into double.
    • getDoubleAndRemove

      double getDoubleAndRemove​(String name, double defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the double value of the first value in insertion order or defaultValue if there is no such value or it can't be converted into double.
    • getTimeMillisAndRemove

      @Nullable Long getTimeMillisAndRemove​(String name)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      Returns:
      the milliseconds value of the first value in insertion order or null if there is no such value or it can't be converted into milliseconds.
    • getTimeMillisAndRemove

      long getTimeMillisAndRemove​(String name, long defaultValue)
      Removes all the parameters with the specified name and returns the parameter value which was added first.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the milliseconds value of the first value in insertion order or defaultValue if there is no such value or it can't be converted into milliseconds.
    • add

      QueryParamsBuilder add​(String name, String value)
      Adds a new parameter with the specified name and value.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • add

      QueryParamsBuilder add​(String name, Iterable<String> values)
      Adds new parameters with the specified name and values. This method is semantically equivalent to
      
       for (String value : values) {
           builder.add(name, value);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • add

      QueryParamsBuilder add​(String name, String... values)
      Adds new parameters with the specified name and values. This method is semantically equivalent to
      
       for (String value : values) {
           builder.add(name, value);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • add

      QueryParamsBuilder add​(Iterable<? extends Map.Entry<? extends String,​String>> entries)
      Adds all parameter names and values of the specified entries.
      Returns:
      this
      Throws:
      IllegalArgumentException - if entries == this.
    • addObject

      QueryParamsBuilder addObject​(String name, Object value)
      Adds a new parameter. The specified parameter value is converted into a String, as explained in Specifying a non-String parameter value.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • addObject

      QueryParamsBuilder addObject​(String name, Iterable<?> values)
      Adds a new parameter with the specified name and values. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value. This method is equivalent to:
      
       for (Object v : values) {
           builder.addObject(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • addObject

      QueryParamsBuilder addObject​(String name, Object... values)
      Adds a new parameter with the specified name and values. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value. This method is equivalent to:
      
       for (Object v : values) {
           builder.addObject(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • addObject

      QueryParamsBuilder addObject​(Iterable<? extends Map.Entry<? extends String,​?>> entries)
      Adds all parameter names and values of the specified entries. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value.
      Returns:
      this
      Throws:
      IllegalArgumentException - if entries == this.
    • addInt

      QueryParamsBuilder addInt​(String name, int value)
      Adds a new parameter.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • addLong

      QueryParamsBuilder addLong​(String name, long value)
      Adds a new parameter.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • addFloat

      QueryParamsBuilder addFloat​(String name, float value)
      Adds a new parameter.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • addDouble

      QueryParamsBuilder addDouble​(String name, double value)
      Adds a new parameter.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • addTimeMillis

      QueryParamsBuilder addTimeMillis​(String name, long value)
      Adds a new parameter.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • set

      QueryParamsBuilder set​(String name, String value)
      Sets a parameter with the specified name and value. Any existing parameters with the same name are overwritten.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • set

      QueryParamsBuilder set​(String name, Iterable<String> values)
      Sets a new parameter with the specified name and values. This method is equivalent to
      
       builder.remove(name);
       for (String v : values) {
           builder.add(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • set

      QueryParamsBuilder set​(String name, String... values)
      Sets a parameter with the specified name and values. Any existing parameters with the specified name are removed. This method is equivalent to:
      
       builder.remove(name);
       for (String v : values) {
           builder.add(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • set

      QueryParamsBuilder set​(Iterable<? extends Map.Entry<? extends String,​String>> entries)
      Retains all current parameters but calls set(String, String) for each entry in the specified entries.
      Parameters:
      entries - the parameters used to set the parameter values
      Returns:
      this
    • setIfAbsent

      QueryParamsBuilder setIfAbsent​(Iterable<? extends Map.Entry<? extends String,​String>> entries)
      Copies the entries missing in this parameters from the specified entries. This method is a shortcut for:
      
       entries.names().forEach(name -> {
           if (!builder.contains(name)) {
               builder.set(name, entries.getAll(name));
           }
       });
       
      Returns:
      this
    • setObject

      QueryParamsBuilder setObject​(String name, Object value)
      Sets a new parameter. Any existing parameters with the specified name are removed. The specified parameter value is converted into a String, as explained in Specifying a non-String parameter value.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • setObject

      QueryParamsBuilder setObject​(String name, Iterable<?> values)
      Sets a parameter with the specified name and values. Any existing parameters with the specified name are removed. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value. This method is equivalent to:
      
       builder.remove(name);
       for (Object v : values) {
           builder.addObject(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • setObject

      QueryParamsBuilder setObject​(String name, Object... values)
      Sets a parameter with the specified name and values. Any existing parameters with the specified name are removed. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value. This method is equivalent to:
      
       builder.remove(name);
       for (Object v : values) {
           builder.addObject(name, v);
       }
       
      Parameters:
      name - the parameter name
      values - the parameter values
      Returns:
      this
    • setObject

      QueryParamsBuilder setObject​(Iterable<? extends Map.Entry<? extends String,​?>> entries)
      Retains all current parameters but calls setObject(String, Object) for each entry in the specified entries. The specified parameter values are converted into Strings, as explained in Specifying a non-String parameter value.
      Parameters:
      entries - the parameters used to set the values in this instance
      Returns:
      this
    • setInt

      QueryParamsBuilder setInt​(String name, int value)
      Sets a parameter with the specified name to value. This will remove all previous values associated with name.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • setLong

      QueryParamsBuilder setLong​(String name, long value)
      Sets a parameter with the specified name to value. This will remove all previous values associated with name.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • setFloat

      QueryParamsBuilder setFloat​(String name, float value)
      Sets a parameter with the specified name to value. This will remove all previous values associated with name.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • setDouble

      QueryParamsBuilder setDouble​(String name, double value)
      Sets a parameter with the specified name to value. This will remove all previous values associated with name.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • setTimeMillis

      QueryParamsBuilder setTimeMillis​(String name, long value)
      Sets a parameter with the specified name to value. This will remove all previous values associated with name.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      this
    • remove

      boolean remove​(String name)
      Removes all parameters with the specified name.
      Parameters:
      name - the parameter name
      Returns:
      true if at least one entry has been removed.
    • removeAndThen

      QueryParamsBuilder removeAndThen​(String name)
      Removes all parameters with the specified name. Unlike remove(String) this method returns itself so that the caller can chain the invocations.
      Parameters:
      name - the parameter name
      Returns:
      this
    • clear

      Removes all parameters. After a call to this method, size() becomes 0.
      Returns:
      this
    • get

      @Nullable String get​(String name)
      Returns the value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the first parameter value if found, or null if there is no such parameter
    • get

      String get​(String name, String defaultValue)
      Returns the value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the first parameter value, or defaultValue if there is no such parameter
    • getAll

      List<String> getAll​(String name)
      Returns all values for the parameter with the specified name. The returned List can't be modified.
      Parameters:
      name - the parameter name
      Returns:
      a List of parameter values or an empty List if there is no such parameter.
    • getInt

      @Nullable Integer getInt​(String name)
      Returns the int value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the int value of the first value in insertion order or null if there is no such parameter or it can't be converted to int.
    • getInt

      int getInt​(String name, int defaultValue)
      Returns the int value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the int value of the first value in insertion order or defaultValue if there is no such parameter or it can't be converted to int.
    • getLong

      @Nullable Long getLong​(String name)
      Returns the long value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the long value of the first value in insertion order or null if there is no such parameter or it can't be converted to long.
    • getLong

      long getLong​(String name, long defaultValue)
      Returns the long value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the long value of the first value in insertion order or defaultValue if there is no such parameter or it can't be converted to long.
    • getFloat

      @Nullable Float getFloat​(String name)
      Returns the float value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the float value of the first value in insertion order or null if there is no such parameter or it can't be converted to float.
    • getFloat

      float getFloat​(String name, float defaultValue)
      Returns the float value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the float value of the first value in insertion order or defaultValue if there is no such parameter or it can't be converted to float.
    • getDouble

      @Nullable Double getDouble​(String name)
      Returns the double value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the double value of the first value in insertion order or null if there is no such parameter or it can't be converted to double.
    • getDouble

      double getDouble​(String name, double defaultValue)
      Returns the double value of a parameter with the specified name. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the double value of the first value in insertion order or defaultValue if there is no such parameter or it can't be converted to double.
    • getTimeMillis

      @Nullable Long getTimeMillis​(String name)
      Returns the value of a parameter with the specified name in milliseconds. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      Returns:
      the milliseconds value of the first value in insertion order or null if there is no such parameter or it can't be converted to milliseconds.
    • getTimeMillis

      long getTimeMillis​(String name, long defaultValue)
      Returns the value of a parameter with the specified name in milliseconds. If there are more than one value for the specified name, the first value in insertion order is returned.
      Parameters:
      name - the parameter name
      defaultValue - the default value
      Returns:
      the milliseconds value of the first value in insertion order or defaultValue if there is no such parameter or it can't be converted to milliseconds.
    • contains

      boolean contains​(String name)
      Returns true if a parameter with the name exists, false otherwise.
      Parameters:
      name - the parameter name
    • contains

      boolean contains​(String name, String value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value to find
    • containsObject

      boolean containsObject​(String name, Object value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • containsInt

      boolean containsInt​(String name, int value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • containsLong

      boolean containsLong​(String name, long value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • containsFloat

      boolean containsFloat​(String name, float value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • containsDouble

      boolean containsDouble​(String name, double value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • containsTimeMillis

      boolean containsTimeMillis​(String name, long value)
      Returns true if a parameter with the name and value exists.
      Parameters:
      name - the parameter name
      value - the parameter value
      Returns:
      true if the parameter exists. false otherwise
    • size

      int size()
      Returns the number of parameters.
    • isEmpty

      boolean isEmpty()
      Returns true if this parameters does not contain any entries.
    • names

      Set<String> names()
      Returns a Set of all parameter names. The returned Set cannot be modified.
    • iterator

      Iterator<Map.Entry<String,​String>> iterator()
      Returns an Iterator that yields all parameter entries.
      Specified by:
      iterator in interface Iterable<Map.Entry<String,​String>>
    • valueIterator

      Iterator<String> valueIterator​(String name)
      Returns an Iterator that yields all values of the parameters with the specified name.
    • forEach

      void forEach​(BiConsumer<String,​String> action)
      Invokes the specified action for all parameter entries.
    • forEachValue

      void forEachValue​(String name, Consumer<String> action)
      Invokes the specified action for all values of the parameters with the specified name.
    • stream

      default Stream<Map.Entry<String,​String>> stream()
      Returns a Stream that yields all parameter entries.
    • valueStream

      default Stream<String> valueStream​(String name)
      Returns a Stream that yields all values of the parameters with the specified name.
    • toQueryString

      default String toQueryString()
      Encodes all parameter entries into a query string, as defined in 4.10.22.6, HTML5 W3C Recommendation.
      Returns:
      the encoded query string.
    • appendQueryString

      default StringBuilder appendQueryString​(StringBuilder buf)
      Encodes all parameter entries into a query string, as defined in 4.10.22.6, HTML5 W3C Recommendation, and appends it into the specified StringBuilder.
      Returns:
      the specified StringBuilder for method chaining.