Package com.linecorp.armeria.common
Interface QueryParamsBuilder
public interface QueryParamsBuilder
Builds a
QueryParams
.- See Also:
QueryParams.builder()
,QueryParams.toBuilder()
-
Method Summary
Modifier and Type Method Description QueryParamsBuilder
add(Iterable<? extends Map.Entry<? extends String,String>> entries)
Adds all parameter names and values of the specifiedentries
.QueryParamsBuilder
add(String name, Iterable<String> values)
Adds new parameters with the specifiedname
andvalues
.QueryParamsBuilder
add(String name, String value)
Adds a new parameter with the specifiedname
andvalue
.QueryParamsBuilder
add(String name, String... values)
Adds new parameters with the specifiedname
andvalues
.QueryParamsBuilder
addDouble(String name, double value)
Adds a new parameter.QueryParamsBuilder
addFloat(String name, float value)
Adds a new parameter.QueryParamsBuilder
addInt(String name, int value)
Adds a new parameter.QueryParamsBuilder
addLong(String name, long value)
Adds a new parameter.QueryParamsBuilder
addObject(Iterable<? extends Map.Entry<? extends String,?>> entries)
Adds all parameter names and values of the specifiedentries
.QueryParamsBuilder
addObject(String name, Iterable<?> values)
Adds a new parameter with the specified name and values.QueryParamsBuilder
addObject(String name, Object value)
Adds a new parameter.QueryParamsBuilder
addObject(String name, Object... values)
Adds a new parameter with the specified name and values.QueryParamsBuilder
addTimeMillis(String name, long value)
Adds a new parameter.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 specifiedStringBuilder
.QueryParams
build()
Returns a newly createdQueryParams
with the entries in this builder.QueryParamsBuilder
clear()
Removes all parameters.boolean
contains(String name)
Returnstrue
if a parameter with thename
exists,false
otherwise.boolean
contains(String name, String value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsDouble(String name, double value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsFloat(String name, float value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsInt(String name, int value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsLong(String name, long value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsObject(String name, Object value)
Returnstrue
if a parameter with thename
andvalue
exists.boolean
containsTimeMillis(String name, long value)
Returnstrue
if a parameter with thename
andvalue
exists.void
forEach(BiConsumer<String,String> action)
Invokes the specifiedaction
for all parameter entries.void
forEachValue(String name, Consumer<String> action)
Invokes the specifiedaction
for all values of the parameters with the specifiedname
.String
get(String name)
Returns the value of a parameter with the specifiedname
.String
get(String name, String defaultValue)
Returns the value of a parameter with the specifiedname
.List<String>
getAll(String name)
Returns all values for the parameter with the specified name.List<String>
getAllAndRemove(String name)
Removes all the parameters with the specified name and returns the removed parameter values.String
getAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.String
getAndRemove(String name, String defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.Double
getDouble(String name)
Returns thedouble
value of a parameter with the specifiedname
.double
getDouble(String name, double defaultValue)
Returns thedouble
value of a parameter with the specifiedname
.Double
getDoubleAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.double
getDoubleAndRemove(String name, double defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.Float
getFloat(String name)
Returns thefloat
value of a parameter with the specifiedname
.float
getFloat(String name, float defaultValue)
Returns thefloat
value of a parameter with the specifiedname
.Float
getFloatAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.float
getFloatAndRemove(String name, float defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.Integer
getInt(String name)
Returns theint
value of a parameter with the specifiedname
.int
getInt(String name, int defaultValue)
Returns theint
value of a parameter with the specifiedname
.Integer
getIntAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.int
getIntAndRemove(String name, int defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.Long
getLong(String name)
Returns thelong
value of a parameter with the specifiedname
.long
getLong(String name, long defaultValue)
Returns thelong
value of a parameter with the specifiedname
.Long
getLongAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.long
getLongAndRemove(String name, long defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.Long
getTimeMillis(String name)
Returns the value of a parameter with the specifiedname
in milliseconds.long
getTimeMillis(String name, long defaultValue)
Returns the value of a parameter with the specifiedname
in milliseconds.Long
getTimeMillisAndRemove(String name)
Removes all the parameters with the specified name and returns the parameter value which was added first.long
getTimeMillisAndRemove(String name, long defaultValue)
Removes all the parameters with the specified name and returns the parameter value which was added first.boolean
isEmpty()
Returnstrue
if this parameters does not contain any entries.Iterator<Map.Entry<String,String>>
iterator()
Returns anIterator
that yields all parameter entries.Set<String>
names()
Returns aSet
of all parameter names.boolean
remove(String name)
Removes all parameters with the specifiedname
.QueryParamsBuilder
removeAndThen(String name)
Removes all parameters with the specifiedname
.QueryParamsBuilder
set(Iterable<? extends Map.Entry<? extends String,String>> entries)
Retains all current parameters but callsset(String, String)
for each entry in the specifiedentries
.QueryParamsBuilder
set(String name, Iterable<String> values)
Sets a new parameter with the specified name and values.QueryParamsBuilder
set(String name, String value)
Sets a parameter with the specified name and value.QueryParamsBuilder
set(String name, String... values)
Sets a parameter with the specified name and values.QueryParamsBuilder
setDouble(String name, double value)
Sets a parameter with the specifiedname
tovalue
.QueryParamsBuilder
setFloat(String name, float value)
Sets a parameter with the specifiedname
tovalue
.QueryParamsBuilder
setIfAbsent(Iterable<? extends Map.Entry<? extends String,String>> entries)
Copies the entries missing in this parameters from the specifiedentries
.QueryParamsBuilder
setInt(String name, int value)
Sets a parameter with the specifiedname
tovalue
.QueryParamsBuilder
setLong(String name, long value)
Sets a parameter with the specifiedname
tovalue
.QueryParamsBuilder
setObject(Iterable<? extends Map.Entry<? extends String,?>> entries)
Retains all current parameters but callssetObject(String, Object)
for each entry in the specifiedentries
.QueryParamsBuilder
setObject(String name, Iterable<?> values)
Sets a parameter with the specified name and values.QueryParamsBuilder
setObject(String name, Object value)
Sets a new parameter.QueryParamsBuilder
setObject(String name, Object... values)
Sets a parameter with the specified name and values.QueryParamsBuilder
setTimeMillis(String name, long value)
Sets a parameter with the specifiedname
tovalue
.int
size()
Returns the number of parameters.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.default Stream<Map.Entry<String,String>>
stream()
Returns aStream
that yields all parameter entries.default String
toQueryString()
Encodes all parameter entries into a query string, as defined in 4.10.22.6, HTML5 W3C Recommendation.Iterator<String>
valueIterator(String name)
Returns anIterator
that yields all values of the parameters with the specifiedname
.default Stream<String>
valueStream(String name)
Returns aStream
that yields all values of the parameters with the specifiedname
.
-
Method Details
-
build
QueryParams build()Returns a newly createdQueryParams
with the entries in this builder. -
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
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
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the first parameter value or
defaultValue
if there is no such parameter
-
getAllAndRemove
Removes all the parameters with the specified name and returns the removed parameter values. -
getIntAndRemove
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 ornull
if there is no such value or it can't be converted intoint
.
-
getIntAndRemove
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
int
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted intoint
.
-
getLongAndRemove
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 ornull
if there is no such value or it can't be converted intolong
.
-
getLongAndRemove
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted intolong
.
-
getFloatAndRemove
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 ornull
if there is no such value or it can't be converted intofloat
.
-
getFloatAndRemove
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted intofloat
.
-
getDoubleAndRemove
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 ornull
if there is no such value or it can't be converted intodouble
.
-
getDoubleAndRemove
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted intodouble
.
-
getTimeMillisAndRemove
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
Removes all the parameters with the specified name and returns the parameter value which was added first.- Parameters:
name
- the parameter namedefaultValue
- 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
Adds a new parameter with the specifiedname
andvalue
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
add
Adds new parameters with the specifiedname
andvalues
. This method is semantically equivalent tofor (String value : values) { builder.add(name, value); }
- Parameters:
name
- the parameter namevalues
- the parameter values- Returns:
this
-
add
Adds new parameters with the specifiedname
andvalues
. This method is semantically equivalent tofor (String value : values) { builder.add(name, value); }
- Parameters:
name
- the parameter namevalues
- the parameter values- Returns:
this
-
add
Adds all parameter names and values of the specifiedentries
.- Returns:
this
- Throws:
IllegalArgumentException
- ifentries == this
.
-
addObject
Adds a new parameter. The specified parameter value is converted into aString
, as explained in Specifying a non-String parameter value.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
addObject
Adds a new parameter with the specified name and values. The specified parameter values are converted intoString
s, 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 namevalues
- the parameter values- Returns:
this
-
addObject
Adds a new parameter with the specified name and values. The specified parameter values are converted intoString
s, 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 namevalues
- the parameter values- Returns:
this
-
addObject
Adds all parameter names and values of the specifiedentries
. The specified parameter values are converted intoString
s, as explained in Specifying a non-String parameter value.- Returns:
this
- Throws:
IllegalArgumentException
- ifentries == this
.
-
addInt
Adds a new parameter.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
addLong
Adds a new parameter.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
addFloat
Adds a new parameter.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
addDouble
Adds a new parameter.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
addTimeMillis
Adds a new parameter.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
set
Sets a parameter with the specified name and value. Any existing parameters with the same name are overwritten.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
set
Sets a new parameter with the specified name and values. This method is equivalent tobuilder.remove(name); for (String v : values) { builder.add(name, v); }
- Parameters:
name
- the parameter namevalues
- the parameter values- Returns:
this
-
set
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 namevalues
- the parameter values- Returns:
this
-
set
Retains all current parameters but callsset(String, String)
for each entry in the specifiedentries
.- Parameters:
entries
- the parameters used to set the parameter values- Returns:
this
-
setIfAbsent
Copies the entries missing in this parameters from the specifiedentries
. This method is a shortcut for:entries.names().forEach(name -> { if (!builder.contains(name)) { builder.set(name, entries.getAll(name)); } });
- Returns:
this
-
setObject
Sets a new parameter. Any existing parameters with the specified name are removed. The specified parameter value is converted into aString
, as explained in Specifying a non-String parameter value.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
setObject
Sets a parameter with the specified name and values. Any existing parameters with the specified name are removed. The specified parameter values are converted intoString
s, 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 namevalues
- the parameter values- Returns:
this
-
setObject
Sets a parameter with the specified name and values. Any existing parameters with the specified name are removed. The specified parameter values are converted intoString
s, 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 namevalues
- the parameter values- Returns:
this
-
setObject
Retains all current parameters but callssetObject(String, Object)
for each entry in the specifiedentries
. The specified parameter values are converted intoString
s, as explained in Specifying a non-String parameter value.- Parameters:
entries
- the parameters used to set the values in this instance- Returns:
this
-
setInt
Sets a parameter with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
setLong
Sets a parameter with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
setFloat
Sets a parameter with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
setDouble
Sets a parameter with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
setTimeMillis
Sets a parameter with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
this
-
remove
Removes all parameters with the specifiedname
.- Parameters:
name
- the parameter name- Returns:
true
if at least one entry has been removed.
-
removeAndThen
Removes all parameters with the specifiedname
. Unlikeremove(String)
this method returns itself so that the caller can chain the invocations.- Parameters:
name
- the parameter name- Returns:
this
-
clear
QueryParamsBuilder clear()Removes all parameters. After a call to this method,size()
becomes0
.- Returns:
this
-
get
Returns the value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, 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
Returns the value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the first parameter value, or
defaultValue
if there is no such parameter
-
getAll
Returns all values for the parameter with the specified name. The returnedList
can't be modified. -
getInt
Returns theint
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter name- Returns:
- the
int
value of the first value in insertion order ornull
if there is no such parameter or it can't be converted toint
.
-
getInt
Returns theint
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
int
value of the first value in insertion order ordefaultValue
if there is no such parameter or it can't be converted toint
.
-
getLong
Returns thelong
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter name- Returns:
- the
long
value of the first value in insertion order ornull
if there is no such parameter or it can't be converted tolong
.
-
getLong
Returns thelong
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such parameter or it can't be converted tolong
.
-
getFloat
Returns thefloat
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter name- Returns:
- the
float
value of the first value in insertion order ornull
if there is no such parameter or it can't be converted tofloat
.
-
getFloat
Returns thefloat
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such parameter or it can't be converted tofloat
.
-
getDouble
Returns thedouble
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter name- Returns:
- the
double
value of the first value in insertion order ornull
if there is no such parameter or it can't be converted todouble
.
-
getDouble
Returns thedouble
value of a parameter with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such parameter or it can't be converted todouble
.
-
getTimeMillis
Returns the value of a parameter with the specifiedname
in milliseconds. If there are more than one value for the specifiedname
, 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
Returns the value of a parameter with the specifiedname
in milliseconds. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the parameter namedefaultValue
- 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
Returnstrue
if a parameter with thename
exists,false
otherwise.- Parameters:
name
- the parameter name
-
contains
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value to find
-
containsObject
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
containsInt
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
containsLong
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
containsFloat
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
containsDouble
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
containsTimeMillis
Returnstrue
if a parameter with thename
andvalue
exists.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
true
if the parameter exists.false
otherwise
-
size
int size()Returns the number of parameters. -
isEmpty
boolean isEmpty()Returnstrue
if this parameters does not contain any entries. -
names
-
iterator
Returns anIterator
that yields all parameter entries. -
valueIterator
Returns anIterator
that yields all values of the parameters with the specifiedname
. -
forEach
Invokes the specifiedaction
for all parameter entries. -
forEachValue
Invokes the specifiedaction
for all values of the parameters with the specifiedname
. -
stream
Returns aStream
that yields all parameter entries. -
valueStream
Returns aStream
that yields all values of the parameters with the specifiedname
. -
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
Encodes all parameter entries into a query string, as defined in 4.10.22.6, HTML5 W3C Recommendation, and appends it into the specifiedStringBuilder
.- Returns:
- the specified
StringBuilder
for method chaining.
-