Class KeyValues

java.lang.Object
io.micrometer.common.KeyValues
All Implemented Interfaces:
Iterable<KeyValue>

public final class KeyValues extends Object implements Iterable<KeyValue>
An immutable collection of KeyValues that are guaranteed to be sorted and deduplicated by key.
Since:
1.10.0
  • Method Details

    • and

      public KeyValues and(String key, String value)
      Return a new KeyValues instance by merging this collection and the specified key/value pair.
      Parameters:
      key - the key to add
      value - the value to add
      Returns:
      a new KeyValues instance
    • and

      public KeyValues and(@Nullable String... keyValues)
      Return a new KeyValues instance by merging this collection and the specified key/value pairs.
      Parameters:
      keyValues - the key/value pairs to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • and

      public KeyValues and(@Nullable KeyValue... keyValues)
      Return a new KeyValues instance by merging this collection and the specified key values.
      Parameters:
      keyValues - the key values to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • and

      public <E> KeyValues and(@Nullable Iterable<E> elements, Function<E,String> keyExtractor, Function<E,String> valueExtractor)
      Return a new KeyValues instance by merging this collection and the key values extracted from the given elements.
      Parameters:
      elements - the source elements
      keyExtractor - function to extract the key from the element
      valueExtractor - function to extract the value from the element
      Returns:
      a new KeyValues instance
    • and

      public KeyValues and(@Nullable Iterable<? extends KeyValue> keyValues)
      Return a new KeyValues instance by merging this collection and the specified key values.
      Parameters:
      keyValues - the key values to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • iterator

      public Iterator<KeyValue> iterator()
      Specified by:
      iterator in interface Iterable<KeyValue>
    • spliterator

      public Spliterator<KeyValue> spliterator()
      Specified by:
      spliterator in interface Iterable<KeyValue>
    • stream

      public Stream<KeyValue> stream()
      Return a stream of the contained key values.
      Returns:
      a key value stream
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • concat

      public static KeyValues concat(@Nullable Iterable<? extends KeyValue> keyValues, @Nullable Iterable<? extends KeyValue> otherKeyValues)
      Return a new KeyValues instance by concatenating the specified collections of key values.
      Parameters:
      keyValues - the first set of key values, elements mustn't be null
      otherKeyValues - the second set of key values, elements mustn't be null
      Returns:
      the merged key values
    • concat

      public static KeyValues concat(@Nullable Iterable<? extends KeyValue> keyValues, @Nullable String... otherKeyValues)
      Return a new KeyValues instance by concatenating the specified key values and key/value pairs.
      Parameters:
      keyValues - the first set of key values, elements mustn't be null
      otherKeyValues - the additional key/value pairs to add, elements mustn't be null
      Returns:
      the merged key values
    • of

      public static <E> KeyValues of(@Nullable Iterable<E> elements, Function<E,String> keyExtractor, Function<E,String> valueExtractor)
      Return a new KeyValues instance containing key values extracted from the given elements.
      Parameters:
      elements - the source elements
      keyExtractor - function to extract the key from the element
      valueExtractor - function to extract the value from the element
      Returns:
      a new KeyValues instance
    • of

      public static KeyValues of(@Nullable Iterable<? extends KeyValue> keyValues)
      Return a new KeyValues instance containing key values constructed from the specified source key values.
      Parameters:
      keyValues - the key values to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • of

      public static KeyValues of(String key, String value)
      Return a new KeyValues instance containing key value constructed from the specified key/value pair.
      Parameters:
      key - the key to add
      value - the value to add
      Returns:
      a new KeyValues instance
    • of

      public static KeyValues of(@Nullable String... keyValues)
      Return a new KeyValues instance containing key values constructed from the specified key/value pairs.
      Parameters:
      keyValues - the key/value pairs to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • of

      public static KeyValues of(@Nullable KeyValue... keyValues)
      Return a new KeyValues instance containing key values constructed from the specified key values.
      Parameters:
      keyValues - the key values to add, elements mustn't be null
      Returns:
      a new KeyValues instance
    • empty

      public static KeyValues empty()
      Return a KeyValues instance that contains no elements.
      Returns:
      an empty KeyValues instance
    • toString

      public String toString()
      Overrides:
      toString in class Object