Class Tags

  • All Implemented Interfaces:
    java.lang.Iterable<Tag>

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Tags and​(Tag... tags)
      Return a new Tags instance by merging this collection and the specified tags.
      Tags and​(java.lang.Iterable<? extends Tag> tags)
      Return a new Tags instance by merging this collection and the specified tags.
      Tags and​(java.lang.String... keyValues)
      Return a new Tags instance by merging this collection and the specified key/value pairs.
      Tags and​(java.lang.String key, java.lang.String value)
      Return a new Tags instance by merging this collection and the specified key/value pair.
      static Tags concat​(java.lang.Iterable<? extends Tag> tags, java.lang.Iterable<Tag> otherTags)
      Return a new Tags instance by concatenating the specified collections of tags.
      static Tags concat​(java.lang.Iterable<? extends Tag> tags, java.lang.String... keyValues)
      Return a new Tags instance by concatenating the specified tags and key/value pairs.
      static Tags empty()
      Return a Tags instance that contains no elements.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      java.util.Iterator<Tag> iterator()  
      static Tags of​(Tag... tags)
      Return a new Tags instance containing tags constructed from the specified tags.
      static Tags of​(java.lang.Iterable<? extends Tag> tags)
      Return a new Tags instance containing tags constructed from the specified source tags.
      static Tags of​(java.lang.String... keyValues)
      Return a new Tags instance containing tags constructed from the specified key/value pairs.
      static Tags of​(java.lang.String key, java.lang.String value)
      Return a new Tags instance containing tags constructed from the specified key/value pair.
      java.util.stream.Stream<Tag> stream()
      Return a stream of the contained tags.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Method Detail

      • and

        public Tags and​(java.lang.String key,
                        java.lang.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
                        java.lang.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
        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
        Returns:
        a new Tags instance
      • and

        public Tags and​(@Nullable
                        java.lang.Iterable<? extends Tag> tags)
        Return a new Tags instance by merging this collection and the specified tags.
        Parameters:
        tags - the tags to add
        Returns:
        a new Tags instance
      • iterator

        public java.util.Iterator<Tag> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Tag>
      • stream

        public java.util.stream.Stream<Tag> stream()
        Return a stream of the contained tags.
        Returns:
        a tags stream
      • hashCode

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

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • concat

        public static Tags concat​(@Nullable
                                  java.lang.Iterable<? extends Tag> tags,
                                  @Nullable
                                  java.lang.Iterable<Tag> otherTags)
        Return a new Tags instance by concatenating the specified collections of tags.
        Parameters:
        tags - the first set of tags
        otherTags - the second set of tags
        Returns:
        the merged tags
      • concat

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

        public static Tags of​(@Nullable
                              java.lang.Iterable<? extends Tag> tags)
        Return a new Tags instance containing tags constructed from the specified source tags.
        Parameters:
        tags - the tags to add
        Returns:
        a new Tags instance
      • of

        public static Tags of​(java.lang.String key,
                              java.lang.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
                              java.lang.String... keyValues)
        Return a new Tags instance containing tags constructed from the specified key/value pairs.
        Parameters:
        keyValues - the key/value pairs to add
        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
        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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object