This class represents a MultiMap of String keys to a List of String values.
It's useful in Vert.x to represent things in Vert.x like HTTP headers and HTTP parameters which allow multiple values for keys.
- Author:
- Norman Maurer, Tim Fox
-
Method Summary
Modifier and TypeMethodDescriptionadd(CharSequence name, CharSequence value) Likeadd(String, String)but acceptingCharSequenceas parametersadd(CharSequence name, Iterable<CharSequence> values) Likeadd(String, Iterable)but acceptingCharSequenceas parametersAdds a new values under the specified nameAdds a new value with the specified name and value.Adds all the entries from another MultiMap to this oneAdds all the entries from a Map to thisstatic MultiMapCreate a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.clear()Removes allbooleancontains(CharSequence name) Likecontains(String)but accepting aCharSequenceas a parameterdefault booleancontains(CharSequence name, CharSequence value, boolean caseInsensitive) Likecontains(String, String, boolean)but acceptingCharSequenceparameters.booleanChecks to see if there is a value with the specified namedefault booleanCheck if there is a header with the specifiednameandvalue.default MultiMapcopy()Returns a mutable copy of this instance.copy(boolean mutable) Returns a copy of this instance.entries()Returns all entries in the multi-map.default voidforEach(BiConsumer<String, String> action) Allows iterating over the entries in the mapget(CharSequence name) Returns the value of with the specified name.getAll(CharSequence name) LikegetAll(String)but accepting aCharSequenceas a parameterReturns the values with the specified namebooleanisEmpty()Return true if emptybooleannames()Gets a immutableSetof all namesremove(CharSequence name) Likeremove(String)but acceptingCharSequenceas parametersRemoves the value with the given nameset(CharSequence name, CharSequence value) Likeset(String, String)but acceptingCharSequenceas parametersset(CharSequence name, Iterable<CharSequence> values) Likeset(String, Iterable)but acceptingCharSequenceas parametersSets values for the specified name.Sets avalueunder the specifiedname.Cleans this instance.Cleans and set all values of the given instanceintsize()Return the number of keys.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
caseInsensitiveMultiMap
Create a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.- Returns:
- the multi-map
-
get
-
get
Returns the value of with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- The name of the header to search- Returns:
- The first header value or
nullif there is no such entry
-
getAll
Returns the values with the specified name- Parameters:
name- The name to search- Returns:
- A immutable
Listof values which will be empty if no values are found
-
getAll
LikegetAll(String)but accepting aCharSequenceas a parameter -
forEach
Allows iterating over the entries in the map -
entries
Returns all entries in the multi-map.- Returns:
- A immutable
Listof the name-value entries, which will be empty if no pairs are found
-
contains
Checks to see if there is a value with the specified name- Parameters:
name- The name to search for- Returns:
- true if at least one entry is found
-
contains
Likecontains(String)but accepting aCharSequenceas a parameter -
contains
Check if there is a header with the specifiednameandvalue. IfcaseInsensitiveistrue,valueis compared in a case-insensitive way.- Parameters:
name- the name to search forvalue- the value to search for- Returns:
trueif at least one entry is found
-
contains
Likecontains(String, String, boolean)but acceptingCharSequenceparameters. -
isEmpty
boolean isEmpty()Return true if empty -
names
Gets a immutableSetof all names- Returns:
- A
Setof all names
-
add
Adds a new value with the specified name and value.- Parameters:
name- The namevalue- The value being added- Returns:
- a reference to this, so the API can be used fluently
-
add
Likeadd(String, String)but acceptingCharSequenceas parameters -
add
Adds a new values under the specified name- Parameters:
name- The name being setvalues- The values- Returns:
- a reference to this, so the API can be used fluently
-
add
Likeadd(String, Iterable)but acceptingCharSequenceas parameters -
addAll
Adds all the entries from another MultiMap to this one- Returns:
- a reference to this, so the API can be used fluently
-
addAll
Adds all the entries from a Map to this- Returns:
- a reference to this, so the API can be used fluently
-
set
Sets avalueunder the specifiedname.If there is an existing header with the same name, it is removed. Setting a
nullvalue removes the entry.- Parameters:
name- The namevalue- The value- Returns:
- a reference to this, so the API can be used fluently
-
set
Likeset(String, String)but acceptingCharSequenceas parameters -
set
Sets values for the specified name.- Parameters:
name- The name of the headers being setvalues- The values of the headers being set- Returns:
- a reference to this, so the API can be used fluently
-
set
Likeset(String, Iterable)but acceptingCharSequenceas parameters -
setAll
Cleans this instance.- Returns:
- a reference to this, so the API can be used fluently
-
setAll
Cleans and set all values of the given instance- Returns:
- a reference to this, so the API can be used fluently
-
remove
Removes the value with the given name- Parameters:
name- The name of the value to remove- Returns:
- a reference to this, so the API can be used fluently
-
remove
Likeremove(String)but acceptingCharSequenceas parameters -
clear
MultiMap clear()Removes all- Returns:
- a reference to this, so the API can be used fluently
-
size
int size()Return the number of keys. -
isMutable
boolean isMutable()- Returns:
- whether this instance can be mutated.
-
copy
Returns a copy of this instance.- Parameters:
mutable- whether the copy can be mutated- Returns:
- a copy of this instance
-
copy
Returns a mutable copy of this instance.- Returns:
- a mutable copy of this instance
-