Package io.opentelemetry.api.internal
Class ImmutableKeyValuePairs<K,V>
- java.lang.Object
-
- io.opentelemetry.api.internal.ImmutableKeyValuePairs<K,V>
-
- Type Parameters:
V
- The type of the values contained in this.
@Immutable public abstract class ImmutableKeyValuePairs<K,V> extends Object
An immutable set of key-value pairs.Key-value pairs are dropped for
null
or empty keys.Note: for subclasses of this, null keys will be removed, but if your key has another concept of being "empty", you'll need to remove them before calling
sortAndFilter(Object[], boolean)
, assuming you don't want the "empty" keys to be kept in your collection.
-
-
Constructor Summary
Constructors Constructor Description ImmutableKeyValuePairs()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Map<K,V>
asMap()
protected abstract List<Object>
data()
V
get(K key)
Returns the value for the givenkey
, ornull
if the key is not present.boolean
isEmpty()
int
size()
static List<Object>
sortAndFilter(Object[] data, boolean filterNullValues)
Sorts and dedupes the key/value pairs indata
.static List<Object>
sortAndFilter(Object[] data, boolean filterNullValues, Comparator<?> keyComparator)
Sorts and dedupes the key/value pairs indata
.String
toString()
-
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
get
@Nullable public V get(K key)
Returns the value for the givenkey
, ornull
if the key is not present.
-
sortAndFilter
public static List<Object> sortAndFilter(Object[] data, boolean filterNullValues)
Sorts and dedupes the key/value pairs indata
. IffilterNullValues
istrue
,null
values will be removed. Keys must beComparable
.
-
sortAndFilter
public static List<Object> sortAndFilter(Object[] data, boolean filterNullValues, Comparator<?> keyComparator)
Sorts and dedupes the key/value pairs indata
. IffilterNullValues
istrue
,null
values will be removed. Keys will be compared with the givenComparator
.
-
-