public interface QueryParamsBuilder
QueryParams.QueryParams.builder(),
QueryParams.toBuilder()| Modifier and Type | Method and Description |
|---|---|
QueryParamsBuilder |
add(Iterable<? extends Map.Entry<? extends String,String>> entries)
Adds all parameter names and values of the specified
entries. |
QueryParamsBuilder |
add(String name,
Iterable<String> values)
Adds new parameters with the specified
name and values. |
QueryParamsBuilder |
add(String name,
String... values)
Adds new parameters with the specified
name and values. |
QueryParamsBuilder |
add(String name,
String value)
Adds a new parameter with the specified
name and value. |
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 specified
entries. |
QueryParamsBuilder |
addObject(String name,
Iterable<?> values)
Adds a new parameter with the specified name and values.
|
QueryParamsBuilder |
addObject(String name,
Object... values)
Adds a new parameter with the specified name and values.
|
QueryParamsBuilder |
addObject(String name,
Object value)
Adds a new parameter.
|
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 specified
StringBuilder. |
QueryParams |
build()
Returns a newly created
QueryParams with the entries in this builder. |
QueryParamsBuilder |
clear()
Removes all parameters.
|
boolean |
contains(String name)
Returns
true if a parameter with the name exists, false otherwise. |
boolean |
contains(String name,
String value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsDouble(String name,
double value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsFloat(String name,
float value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsInt(String name,
int value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsLong(String name,
long value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsObject(String name,
Object value)
Returns
true if a parameter with the name and value exists. |
boolean |
containsTimeMillis(String name,
long value)
Returns
true if a parameter with the name and value exists. |
void |
forEach(BiConsumer<String,String> action)
Invokes the specified
action for all parameter entries. |
void |
forEachValue(String name,
Consumer<String> action)
Invokes the specified
action for all values of the parameters with the specified name. |
String |
get(String name)
Returns the value of a parameter with the specified
name. |
String |
get(String name,
String defaultValue)
Returns the value of a parameter with the specified
name. |
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 the
double value of a parameter with the specified name. |
double |
getDouble(String name,
double defaultValue)
Returns the
double value of a parameter with the specified name. |
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 the
float value of a parameter with the specified name. |
float |
getFloat(String name,
float defaultValue)
Returns the
float value of a parameter with the specified name. |
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 the
int value of a parameter with the specified name. |
int |
getInt(String name,
int defaultValue)
Returns the
int value of a parameter with the specified name. |
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 the
long value of a parameter with the specified name. |
long |
getLong(String name,
long defaultValue)
Returns the
long value of a parameter with the specified name. |
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 specified
name in milliseconds. |
long |
getTimeMillis(String name,
long defaultValue)
Returns the value of a parameter with the specified
name 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()
Returns
true if this parameters does not contain any entries. |
Iterator<Map.Entry<String,String>> |
iterator()
Returns an
Iterator that yields all parameter entries. |
Set<String> |
names()
Returns a
Set of all parameter names. |
boolean |
remove(String name)
Removes all parameters with the specified
name. |
QueryParamsBuilder |
removeAndThen(String name)
Removes all parameters with the specified
name. |
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. |
QueryParamsBuilder |
set(String name,
Iterable<String> values)
Sets a new parameter with the specified name and values.
|
QueryParamsBuilder |
set(String name,
String... values)
Sets a parameter with the specified name and values.
|
QueryParamsBuilder |
set(String name,
String value)
Sets a parameter with the specified name and value.
|
QueryParamsBuilder |
setDouble(String name,
double value)
Sets a parameter with the specified
name to value. |
QueryParamsBuilder |
setFloat(String name,
float value)
Sets a parameter with the specified
name to value. |
QueryParamsBuilder |
setIfAbsent(Iterable<? extends Map.Entry<? extends String,String>> entries)
Copies the entries missing in this parameters from the specified
entries. |
QueryParamsBuilder |
setInt(String name,
int value)
Sets a parameter with the specified
name to value. |
QueryParamsBuilder |
setLong(String name,
long value)
Sets a parameter with the specified
name to value. |
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. |
QueryParamsBuilder |
setObject(String name,
Iterable<?> values)
Sets a parameter with the specified name and values.
|
QueryParamsBuilder |
setObject(String name,
Object... values)
Sets a parameter with the specified name and values.
|
QueryParamsBuilder |
setObject(String name,
Object value)
Sets a new parameter.
|
QueryParamsBuilder |
setTimeMillis(String name,
long value)
Sets a parameter with the specified
name to value. |
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 a
Stream 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 an
Iterator that yields all values of the parameters with the specified name. |
default Stream<String> |
valueStream(String name)
Returns a
Stream that yields all values of the parameters with the specified name. |
forEach, spliteratorQueryParams build()
QueryParams with the entries in this builder.QueryParamsBuilder sizeHint(int sizeHint)
thisIllegalStateException - if the hint was specified too late after the underlying data structure
has been fully initialized.String getAndRemove(String name)
name - the parameter namenull if there is no such parameterString getAndRemove(String name, String defaultValue)
name - the parameter namedefaultValue - the default valuedefaultValue if there is no such parameterList<String> getAllAndRemove(String name)
Integer getIntAndRemove(String name)
name - the parameter nameint value of the first value in insertion order or null if there is no
such value or it can't be converted into int.int getIntAndRemove(String name, int defaultValue)
name - the parameter namedefaultValue - the default valueint value of the first value in insertion order or defaultValue if there is
no such value or it can't be converted into int.Long getLongAndRemove(String name)
name - the parameter namelong value of the first value in insertion order or null if there is no such
value or it can't be converted into long.long getLongAndRemove(String name, long defaultValue)
name - the parameter namedefaultValue - the default valuelong value of the first value in insertion order or defaultValue if there is
no such value or it can't be converted into long.Float getFloatAndRemove(String name)
name - the parameter namefloat value of the first value in insertion order or null if there is
no such value or it can't be converted into float.float getFloatAndRemove(String name, float defaultValue)
name - the parameter namedefaultValue - the default valuefloat value of the first value in insertion order or defaultValue if there
is no such value or it can't be converted into float.Double getDoubleAndRemove(String name)
name - the parameter namedouble value of the first value in insertion order or null if there is
no such value or it can't be converted into double.double getDoubleAndRemove(String name, double defaultValue)
name - the parameter namedefaultValue - the default valuedouble value of the first value in insertion order or defaultValue if there
is no such value or it can't be converted into double.Long getTimeMillisAndRemove(String name)
name - the parameter namenull if there is no such
value or it can't be converted into milliseconds.long getTimeMillisAndRemove(String name, long defaultValue)
name - the parameter namedefaultValue - the default valuedefaultValue if there is
no such value or it can't be converted into milliseconds.QueryParamsBuilder add(String name, String value)
name and value.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder add(String name, Iterable<String> values)
name and values. This method is semantically
equivalent to
for (String value : values) {
builder.add(name, value);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder add(String name, String... values)
name and values. This method is semantically
equivalent to
for (String value : values) {
builder.add(name, value);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder add(Iterable<? extends Map.Entry<? extends String,String>> entries)
entries.thisIllegalArgumentException - if entries == this.QueryParamsBuilder addObject(String name, Object value)
String, as explained
in Specifying a non-String parameter value.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder addObject(String name, Iterable<?> values)
Strings, as explained in Specifying a
non-String parameter value. This method is equivalent to:
for (Object v : values) {
builder.addObject(name, v);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder addObject(String name, Object... values)
Strings, as explained in Specifying a
non-String parameter value. This method is equivalent to:
for (Object v : values) {
builder.addObject(name, v);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder addObject(Iterable<? extends Map.Entry<? extends String,?>> entries)
entries. The specified parameter values are
converted into Strings, as explained in Specifying
a non-String parameter value.thisIllegalArgumentException - if entries == this.QueryParamsBuilder addInt(String name, int value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder addLong(String name, long value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder addFloat(String name, float value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder addDouble(String name, double value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder addTimeMillis(String name, long value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder set(String name, String value)
name - the parameter namevalue - the parameter valuethisQueryParamsBuilder set(String name, Iterable<String> values)
builder.remove(name);
for (String v : values) {
builder.add(name, v);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder set(String name, String... values)
builder.remove(name);
for (String v : values) {
builder.add(name, v);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder set(Iterable<? extends Map.Entry<? extends String,String>> entries)
set(String, String) for each entry in
the specified entries.entries - the parameters used to set the parameter valuesthisQueryParamsBuilder setIfAbsent(Iterable<? extends Map.Entry<? extends String,String>> entries)
entries.
This method is a shortcut for:
entries.names().forEach(name -> {
if (!builder.contains(name)) {
builder.set(name, entries.getAll(name));
}
});
thisQueryParamsBuilder setObject(String name, Object value)
String, as explained in
Specifying a non-String parameter value.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder setObject(String name, Iterable<?> values)
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);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder setObject(String name, Object... values)
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);
}
name - the parameter namevalues - the parameter valuesthisQueryParamsBuilder setObject(Iterable<? extends Map.Entry<? extends String,?>> entries)
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.entries - the parameters used to set the values in this instancethisQueryParamsBuilder setInt(String name, int value)
name to value. This will remove all previous values
associated with name.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder setLong(String name, long value)
name to value. This will remove all previous values
associated with name.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder setFloat(String name, float value)
name to value. This will remove all previous values
associated with name.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder setDouble(String name, double value)
name to value. This will remove all previous values
associated with name.name - the parameter namevalue - the parameter valuethisQueryParamsBuilder setTimeMillis(String name, long value)
name to value. This will remove all previous values
associated with name.name - the parameter namevalue - the parameter valuethisboolean remove(String name)
name.name - the parameter nametrue if at least one entry has been removed.QueryParamsBuilder removeAndThen(String name)
name. Unlike remove(String)
this method returns itself so that the caller can chain the invocations.name - the parameter namethisQueryParamsBuilder clear()
size() becomes 0.thisString get(String name)
name. If there are more than one value for
the specified name, the first value in insertion order is returned.name - the parameter namenull if there is no such parameterString get(String name, String defaultValue)
name. If there are more than one value for
the specified name, the first value in insertion order is returned.name - the parameter namedefaultValue - the default valuedefaultValue if there is no such parameterList<String> getAll(String name)
List can't be
modified.Integer getInt(String name)
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.name - the parameter nameint value of the first value in insertion order or null if there is no such
parameter or it can't be converted to int.int getInt(String name, int defaultValue)
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.name - the parameter namedefaultValue - the default valueint value of the first value in insertion order or defaultValue if there is
no such parameter or it can't be converted to int.Long getLong(String name)
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.name - the parameter namelong value of the first value in insertion order or null if there is no such
parameter or it can't be converted to long.long getLong(String name, long defaultValue)
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.name - the parameter namedefaultValue - the default valuelong value of the first value in insertion order or defaultValue if there is
no such parameter or it can't be converted to long.Float getFloat(String name)
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.name - the parameter namefloat value of the first value in insertion order or null if there is no
such parameter or it can't be converted to float.float getFloat(String name, float defaultValue)
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.name - the parameter namedefaultValue - the default valuefloat value of the first value in insertion order or defaultValue if there
is no such parameter or it can't be converted to float.Double getDouble(String name)
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.name - the parameter namedouble value of the first value in insertion order or null if there is no
such parameter or it can't be converted to double.double getDouble(String name, double defaultValue)
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.name - the parameter namedefaultValue - the default valuedouble value of the first value in insertion order or defaultValue if there
is no such parameter or it can't be converted to double.Long getTimeMillis(String name)
name in milliseconds. If there are more than
one value for the specified name, the first value in insertion order is returned.name - the parameter namenull if there is no such
parameter or it can't be converted to milliseconds.long getTimeMillis(String name, long defaultValue)
name in milliseconds. If there are more than
one value for the specified name, the first value in insertion order is returned.name - the parameter namedefaultValue - the default valuedefaultValue if there is
no such parameter or it can't be converted to milliseconds.boolean contains(String name)
true if a parameter with the name exists, false otherwise.name - the parameter nameboolean contains(String name, String value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter value to findboolean containsObject(String name, Object value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseboolean containsInt(String name, int value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseboolean containsLong(String name, long value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseboolean containsFloat(String name, float value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseboolean containsDouble(String name, double value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseboolean containsTimeMillis(String name, long value)
true if a parameter with the name and value exists.name - the parameter namevalue - the parameter valuetrue if the parameter exists. false otherwiseint size()
boolean isEmpty()
true if this parameters does not contain any entries.Iterator<Map.Entry<String,String>> iterator()
Iterator that yields all parameter entries.Iterator<String> valueIterator(String name)
Iterator that yields all values of the parameters with the specified name.void forEach(BiConsumer<String,String> action)
action for all parameter entries.void forEachValue(String name, Consumer<String> action)
action for all values of the parameters with the specified name.default Stream<Map.Entry<String,String>> stream()
Stream that yields all parameter entries.default Stream<String> valueStream(String name)
Stream that yields all values of the parameters with the specified name.default String toQueryString()
default StringBuilder appendQueryString(StringBuilder buf)
StringBuilder.StringBuilder for method chaining.Copyright © 2020 LeanCloud. All rights reserved.