Package co.elastic.apm.agent.util
Class PotentiallyMultiValuedMap
- java.lang.Object
-
- co.elastic.apm.agent.util.PotentiallyMultiValuedMap
-
- All Implemented Interfaces:
Recyclable
public class PotentiallyMultiValuedMap extends java.lang.Object implements Recyclable
This map is a mixture of a map with a single value and a map with multiple values.When there is only one value associated with a key, this map just the key as-is when calling
get(String). But whenadd(String, String)has been called multiple times for a given key,get(String)will return a collection of values.
-
-
Constructor Summary
Constructors Constructor Description PotentiallyMultiValuedMap()PotentiallyMultiValuedMap(int initialSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String key, java.lang.String value)Adds a value to this map.booleancontainsIgnoreCase(java.lang.String key)voidcopyFrom(PotentiallyMultiValuedMap other)java.lang.Objectget(java.lang.String key)java.util.List<java.lang.String>getAll(java.lang.String key)Gets all the values which age associated with a given key.java.lang.StringgetFirst(java.lang.String key)Gets the first value which is associated with a given key.java.lang.StringgetKey(int i)java.lang.ObjectgetValue(int i)booleanisEmpty()voidremoveIgnoreCase(java.lang.String key)voidresetState()resets pooled object state so it can be reusedvoidset(int index, java.lang.String value)voidset(java.lang.String key, java.lang.String[] values)intsize()
-
-
-
Method Detail
-
add
public void add(java.lang.String key, java.lang.String value)Adds a value to this map.If the given key already exists, the current value and the given value are added to a collection, which is set as the new value.
- Parameters:
key- The key.value- The value.
-
set
public void set(java.lang.String key, java.lang.String[] values)
-
getFirst
@Nullable public java.lang.String getFirst(java.lang.String key)
Gets the first value which is associated with a given key.- Parameters:
key- The key you want to get the associated value for.- Returns:
- The first value which is associated with a given key.
-
get
@Nullable public java.lang.Object get(java.lang.String key)
-
getAll
public java.util.List<java.lang.String> getAll(java.lang.String key)
Gets all the values which age associated with a given key.If there is only one value associated with the given key, the value is wrapped inside a collection.
- Parameters:
key- The key you want to get the associated value for.- Returns:
- All the values which age associated with a given key.
-
isEmpty
public boolean isEmpty()
-
resetState
public void resetState()
Description copied from interface:Recyclableresets pooled object state so it can be reused- Specified by:
resetStatein interfaceRecyclable
-
getKey
public java.lang.String getKey(int i)
-
getValue
public java.lang.Object getValue(int i)
-
size
public int size()
-
copyFrom
public void copyFrom(PotentiallyMultiValuedMap other)
-
removeIgnoreCase
public void removeIgnoreCase(java.lang.String key)
-
set
public void set(int index, java.lang.String value)
-
containsIgnoreCase
public boolean containsIgnoreCase(java.lang.String key)
-
-