Class Tags

java.lang.Object
io.micrometer.core.instrument.Tags
All Implemented Interfaces:
Iterable<Tag>

public final class Tags extends Object implements Iterable<Tag>
An immutable collection of Tags that are guaranteed to be sorted and deduplicated by tag key.
  • Method Summary

    Modifier and Type
    Method
    Description
    and(Tag... tags)
    Return a new Tags instance by merging this collection and the specified tags.
    and(Iterable<? extends Tag> tags)
    Return a new Tags instance by merging this collection and the specified tags.
    and(String... keyValues)
    Return a new Tags instance by merging this collection and the specified key/value pairs.
    and(String key, String value)
    Return a new Tags instance by merging this collection and the specified key/value pair.
    static Tags
    concat(Iterable<? extends Tag> tags, Iterable<? extends Tag> otherTags)
    Return a new Tags instance by concatenating the specified collections of tags.
    static Tags
    concat(Iterable<? extends Tag> tags, String... keyValues)
    Return a new Tags instance by concatenating the specified tags and key/value pairs.
    static Tags
    Return a Tags instance that contains no elements.
    boolean
     
    int
     
     
    static Tags
    of(Tag... tags)
    Return a new Tags instance containing tags constructed from the specified tags.
    static Tags
    of(Iterable<? extends Tag> tags)
    Return a new Tags instance containing tags constructed from the specified source tags.
    static Tags
    of(String... keyValues)
    Return a new Tags instance containing tags constructed from the specified key/value pairs.
    static Tags
    of(String key, String value)
    Return a new Tags instance containing tags constructed from the specified key/value pair.
     
    Return a stream of the contained tags.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach
  • Method Details

    • and

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

      public Tags and(@Nullable String... keyValues)
      Return a new Tags 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 Tags instance
    • and

      public Tags and(@Nullable Tag... tags)
      Return a new Tags instance by merging this collection and the specified tags.
      Parameters:
      tags - the tags to add, elements mustn't be null
      Returns:
      a new Tags instance
    • and

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

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

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

      public Stream<Tag> stream()
      Return a stream of the contained tags.
      Returns:
      a tags 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 Tags concat(@Nullable Iterable<? extends Tag> tags, @Nullable Iterable<? extends Tag> otherTags)
      Return a new Tags instance by concatenating the specified collections of tags.
      Parameters:
      tags - the first set of tags, elements mustn't be null
      otherTags - the second set of tags, elements mustn't be null
      Returns:
      the merged tags
    • concat

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

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

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

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

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

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

      public String toString()
      Overrides:
      toString in class Object