public class KeyValues extends Object
This class represents a key-value data structure with following features:
This structure is used in Jadler for modeling request/response headers and request parameters.
Please note this class is immutable and therefore thread safe. All addition operations
(add(java.lang.String, java.lang.String)
, addAll(net.jadler.KeyValues)
create new instances
rather than modifying the instance.
Request
,
StubResponse
Modifier and Type | Field and Description |
---|---|
static KeyValues |
EMPTY
An empty instance.
|
Constructor and Description |
---|
KeyValues()
Creates new empty instance.
|
Modifier and Type | Method and Description |
---|---|
KeyValues |
add(String key,
String value)
Adds new key-value pair.
|
KeyValues |
addAll(KeyValues keyValues)
Adds all values from the given instance.
|
boolean |
equals(Object obj) |
Set<String> |
getKeys() |
String |
getValue(String key)
Returns the first value for the given key
|
List<String> |
getValues(String key)
Returns all values for the given key
|
int |
hashCode() |
String |
toString() |
public static final KeyValues EMPTY
public KeyValues add(String key, String value)
key
- key (cannot be empty)value
- value (cannot be null
, however can be empty for valueless headers)public KeyValues addAll(KeyValues keyValues)
keyValues
- values to be added no(cannot be null
)public String getValue(String key)
key
- key (case insensitive)null
, if there is no such a key in this instancepublic List<String> getValues(String key)
key
- key (case insensitive)null
, if there is no such a key in this instancepublic Set<String> getKeys()
null
)Copyright © 2016. All Rights Reserved.