Package io.vertx.core
Interface MultiMap
-
public interface MultiMap extends Iterable<Map.Entry<String,String>>
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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description MultiMapadd(CharSequence name, CharSequence value)Likeadd(String, String)but acceptingCharSequenceas parametersMultiMapadd(CharSequence name, Iterable<CharSequence> values)Likeadd(String, Iterable)but acceptingCharSequenceas parametersMultiMapadd(String name, Iterable<String> values)Adds a new values under the specified nameMultiMapadd(String name, String value)Adds a new value with the specified name and value.MultiMapaddAll(MultiMap map)Adds all the entries from another MultiMap to this oneMultiMapaddAll(Map<String,String> headers)Adds all the entries from a Map to thisstatic MultiMapcaseInsensitiveMultiMap()Create a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.MultiMapclear()Removes allbooleancontains(CharSequence name)Likecontains(String)but accepting aCharSequenceas a parameterdefault booleancontains(CharSequence name, CharSequence value, boolean caseInsensitive)Likecontains(String, String, boolean)but acceptingCharSequenceparameters.booleancontains(String name)Checks to see if there is a value with the specified namedefault booleancontains(String name, String value, boolean caseInsensitive)Check if there is a header with the specifiednameandvalue.default MultiMapcopy()Returns a mutable copy of this instance.MultiMapcopy(boolean mutable)Returns a copy of this instance.default List<Map.Entry<String,String>>entries()Returns all entries in the multi-map.default voidforEach(BiConsumer<String,String> action)Allows iterating over the entries in the mapStringget(CharSequence name)Stringget(String name)Returns the value of with the specified name.List<String>getAll(CharSequence name)LikegetAll(String)but accepting aCharSequenceas a parameterList<String>getAll(String name)Returns the values with the specified namebooleanisEmpty()Return true if emptybooleanisMutable()Set<String>names()Gets a immutableSetof all namesMultiMapremove(CharSequence name)Likeremove(String)but acceptingCharSequenceas parametersMultiMapremove(String name)Removes the value with the given nameMultiMapset(CharSequence name, CharSequence value)Likeset(String, String)but acceptingCharSequenceas parametersMultiMapset(CharSequence name, Iterable<CharSequence> values)Likeset(String, Iterable)but acceptingCharSequenceas parametersMultiMapset(String name, Iterable<String> values)Sets values for the specified name.MultiMapset(String name, String value)Sets avalueunder the specifiedname.MultiMapsetAll(MultiMap map)Cleans this instance.MultiMapsetAll(Map<String,String> headers)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 Detail
-
caseInsensitiveMultiMap
static MultiMap 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
String get(CharSequence name)
-
get
String get(String name)
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
List<String> getAll(String name)
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
List<String> getAll(CharSequence name)
LikegetAll(String)but accepting aCharSequenceas a parameter
-
forEach
default void forEach(BiConsumer<String,String> action)
Allows iterating over the entries in the map
-
entries
default List<Map.Entry<String,String>> 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
boolean contains(String name)
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
boolean contains(CharSequence name)
Likecontains(String)but accepting aCharSequenceas a parameter
-
contains
default boolean contains(String name, String value, boolean caseInsensitive)
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
default boolean contains(CharSequence name, CharSequence value, boolean caseInsensitive)
Likecontains(String, String, boolean)but acceptingCharSequenceparameters.
-
isEmpty
boolean isEmpty()
Return true if empty
-
add
MultiMap add(String name, String value)
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
MultiMap add(CharSequence name, CharSequence value)
Likeadd(String, String)but acceptingCharSequenceas parameters
-
add
MultiMap add(String name, Iterable<String> values)
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
MultiMap add(CharSequence name, Iterable<CharSequence> values)
Likeadd(String, Iterable)but acceptingCharSequenceas parameters
-
addAll
MultiMap addAll(MultiMap map)
Adds all the entries from another MultiMap to this one- Returns:
- a reference to this, so the API can be used fluently
-
addAll
MultiMap addAll(Map<String,String> headers)
Adds all the entries from a Map to this- Returns:
- a reference to this, so the API can be used fluently
-
set
MultiMap set(String name, String value)
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
MultiMap set(CharSequence name, CharSequence value)
Likeset(String, String)but acceptingCharSequenceas parameters
-
set
MultiMap set(String name, Iterable<String> values)
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
MultiMap set(CharSequence name, Iterable<CharSequence> values)
Likeset(String, Iterable)but acceptingCharSequenceas parameters
-
setAll
MultiMap setAll(MultiMap map)
Cleans this instance.- Returns:
- a reference to this, so the API can be used fluently
-
setAll
MultiMap setAll(Map<String,String> headers)
Cleans and set all values of the given instance- Returns:
- a reference to this, so the API can be used fluently
-
remove
MultiMap remove(String name)
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
MultiMap remove(CharSequence name)
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
MultiMap copy(boolean mutable)
Returns a copy of this instance.- Parameters:
mutable- whether the copy can be mutated- Returns:
- a copy of this instance
-
copy
default MultiMap copy()
Returns a mutable copy of this instance.- Returns:
- a mutable copy of this instance
-
-