Class LangCollectors


  • public final class LangCollectors
    extends java.lang.Object
    Implementations of Collector that implement various useful reduction operations.

    This class is called LangCollectors instead of Collectors to avoid clashes with Collectors.

    Since:
    3.13.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  LangCollectors.SimpleCollector<T,​A,​R>
      Simple implementation class for Collector.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Set<java.util.stream.Collector.Characteristics> CH_NOID  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LangCollectors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining()
      Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.
      static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter)
      Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.
      static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter, java.lang.CharSequence prefix, java.lang.CharSequence suffix)
      Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.
      static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter, java.lang.CharSequence prefix, java.lang.CharSequence suffix, java.util.function.Function<java.lang.Object,​java.lang.String> toString)
      Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CH_NOID

        private static final java.util.Set<java.util.stream.Collector.Characteristics> CH_NOID
    • Constructor Detail

      • LangCollectors

        private LangCollectors()
    • Method Detail

      • joining

        public static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining()
        Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.

        This is a variation of Collectors.joining() that works with any element class, not just CharSequence.

        Returns:
        A Collector which concatenates Object elements, separated by the specified delimiter, in encounter order.
      • joining

        public static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter)
        Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.

        This is a variation of Collectors.joining(CharSequence) that works with any element class, not just CharSequence.

        Parameters:
        delimiter - the delimiter to be used between each element.
        Returns:
        A Collector which concatenates Object elements, separated by the specified delimiter, in encounter order.
      • joining

        public static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter,
                                                                                                          java.lang.CharSequence prefix,
                                                                                                          java.lang.CharSequence suffix)
        Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.

        This is a variation of Collectors.joining(CharSequence, CharSequence, CharSequence) that works with any element class, not just CharSequence.

        Parameters:
        delimiter - the delimiter to be used between each element
        prefix - the sequence of characters to be used at the beginning of the joined result
        suffix - the sequence of characters to be used at the end of the joined result
        Returns:
        A Collector which concatenates CharSequence elements, separated by the specified delimiter, in encounter order
      • joining

        public static java.util.stream.Collector<java.lang.Object,​?,​java.lang.String> joining​(java.lang.CharSequence delimiter,
                                                                                                          java.lang.CharSequence prefix,
                                                                                                          java.lang.CharSequence suffix,
                                                                                                          java.util.function.Function<java.lang.Object,​java.lang.String> toString)
        Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.

        This is a variation of Collectors.joining(CharSequence, CharSequence, CharSequence) that works with any element class, not just CharSequence.

        Parameters:
        delimiter - the delimiter to be used between each element
        prefix - the sequence of characters to be used at the beginning of the joined result
        suffix - the sequence of characters to be used at the end of the joined result
        toString - A function that takes an Object and returns a non-null String.
        Returns:
        A Collector which concatenates CharSequence elements, separated by the specified delimiter, in encounter order