@Immutable public abstract class Labels extends Object
String.| Modifier and Type | Class and Description |
|---|---|
static class |
Labels.Builder
Enables the creation of an
Labels instance with an arbitrary number of key-value pairs. |
ReadableKeyValuePairs.KeyValueConsumer<V>| Constructor and Description |
|---|
Labels() |
| Modifier and Type | Method and Description |
|---|---|
static Labels |
empty()
Returns a
Labels instance with no attributes. |
void |
forEach(ReadableKeyValuePairs.KeyValueConsumer<V> consumer)
Iterates over all the key-value pairs of attributes contained by this instance.
|
V |
get(String key)
Returns the value of the given key, or null if the key does not exist.
|
boolean |
isEmpty()
Whether there are any attributes contained in this.
|
static Labels.Builder |
newBuilder()
Creates a new
Labels.Builder instance for creating arbitrary Labels. |
static Labels |
of(String[] keyValueLabelPairs) |
static Labels |
of(String key,
String value)
Returns a
Labels instance with a single key-value pair. |
static Labels |
of(String key1,
String value1,
String key2,
String value2)
Returns a
Labels instance with two key-value pairs. |
static Labels |
of(String key1,
String value1,
String key2,
String value2,
String key3,
String value3)
Returns a
Labels instance with three key-value pairs. |
static Labels |
of(String key1,
String value1,
String key2,
String value2,
String key3,
String value3,
String key4,
String value4)
Returns a
Labels instance with four key-value pairs. |
static Labels |
of(String key1,
String value1,
String key2,
String value2,
String key3,
String value3,
String key4,
String value4,
String key5,
String value5)
Returns a
Labels instance with five key-value pairs. |
int |
size()
The number of attributes contained in this.
|
public static Labels of(String key, String value)
Labels instance with a single key-value pair.public static Labels of(String key1, String value1, String key2, String value2)
Labels instance with two key-value pairs. Order of the keys is not preserved.
Duplicate keys will be removed.public static Labels of(String key1, String value1, String key2, String value2, String key3, String value3)
Labels instance with three key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static Labels of(String key1, String value1, String key2, String value2, String key3, String value3, String key4, String value4)
Labels instance with four key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static Labels of(String key1, String value1, String key2, String value2, String key3, String value3, String key4, String value4, String key5, String value5)
Labels instance with five key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static Labels.Builder newBuilder()
Labels.Builder instance for creating arbitrary Labels.public int size()
ReadableKeyValuePairssize in interface ReadableKeyValuePairs<V>public boolean isEmpty()
ReadableKeyValuePairsisEmpty in interface ReadableKeyValuePairs<V>public void forEach(ReadableKeyValuePairs.KeyValueConsumer<V> consumer)
ReadableKeyValuePairsforEach in interface ReadableKeyValuePairs<V>@Nullable public V get(String key)
ReadableKeyValuePairsCurrently may be implemented via a linear search, depending on implementation, so O(n) performance in the worst case.
get in interface ReadableKeyValuePairs<V>