Class LangCollectors


  • public final class LangCollectors
    extends 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
    • Method Detail

      • joining

        public static Collector<Object,​?,​Stringjoining()
        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 Collector<Object,​?,​Stringjoining​(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 Collector<Object,​?,​Stringjoining​(CharSequence delimiter,
                                                                     CharSequence prefix,
                                                                     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 Collector<Object,​?,​Stringjoining​(CharSequence delimiter,
                                                                     CharSequence prefix,
                                                                     CharSequence suffix,
                                                                     Function<Object,​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