Interface NewlineProcessor


  • public interface NewlineProcessor
    A processor for a specific type of newline. Can split a string into lines, and format a list of lines into a string.
    Since:
    8.2.0
    • Method Detail

      • filter

        NewlineProcessor filter​(Predicate<? super String> filter)
        Creates a newline processor that behaves like this processor, but filters out lines that do not match the given predicate. When splitting, such lines are omitted from the returned lines. When formatting, such lines are omitted from the formatted output.
        Parameters:
        filter - The filter to apply.
        Returns:
        A newline processor that behaves like the given processor, but filters out lines that do not match the
      • format

        String format​(Iterable<?> lines)
        Formats the given enumeration of lines into a single string, using this type of line separator. Each line may be any arbitrary object, which will be converted to a string using its Object.toString() method. When null, the line will be formatted as an empty string. A null value for lines will be treated as an empty.
        Parameters:
        lines - The lines to format.
        Returns:
        The formatted string.
      • format

        String format​(Stream<?> lines)
        Formats the given enumeration of lines into a single string, using this type of line separator. Each line may be any arbitrary object, which will be converted to a string using its Object.toString() method. When null, the line will be formatted as an empty string. A null value for lines will be treated as an empty.
        Parameters:
        lines - The lines to format.
        Returns:
        The formatted string.
      • format

        String format​(Iterator<?> lines)
        Formats the given enumeration of lines into a single string, using this type of line separator. Each line may be any arbitrary object, which will be converted to a string using its Object.toString() method. When null, the line will be formatted as an empty string. A null value for lines will be treated as an empty.
        Parameters:
        lines - The lines to format.
        Returns:
        The formatted string.
      • format

        String format​(Object... lines)
        Formats the given enumeration of lines into a single string, using this type of line separator. Each line may be any arbitrary object, which will be converted to a string using its Object.toString() method. When null, the line will be formatted as an empty string. A null value for lines will be treated as an empty.
        Parameters:
        lines - The lines to format.
        Returns:
        The formatted string.
      • format

        String format​(Enumeration<?> lines)
        Formats the given enumeration of lines into a single string, using this type of line separator. Each line may be any arbitrary object, which will be converted to a string using its Object.toString() method. When null, the line will be formatted as an empty string. A null value for lines will be treated as an empty.
        Parameters:
        lines - The lines to format.
        Returns:
        The formatted string.
      • map

        NewlineProcessor map​(UnaryOperator<String> mapper)
        Creates a newline processor that behaves like this processor, but maps each line using the given mapper. When splitting, the lines are mapped before being returned. When formatting, the lines are mapped before being formatted.
        Parameters:
        mapper - The mapper to apply.
        Returns:
        A newline processor that behaves like the given processor, but maps each line using the given mapper.
      • split

        <Intermediate,​Container> Container split​(String value,
                                                       Collector<? super String,​Intermediate,​? extends Container> collector)
        Splits the given string by this type of line separator and collects the result using the given collector. A null value will be treated as an empty string.
        Type Parameters:
        Intermediate - The intermediate container type.
        Container - The final result type.
        Parameters:
        value - The string to split.
        collector - The collector to use.
        Returns:
        The collected result.
      • splitToArray

        String[] splitToArray​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        An array of lines.
      • splitToEnumeration

        Enumeration<String> splitToEnumeration​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        An enumeration over the lines.
      • splitToIterable

        Iterable<String> splitToIterable​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        An iterable over the lines.
      • splitToIterator

        Iterator<String> splitToIterator​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        An iterator over the lines.
      • splitToList

        List<String> splitToList​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        An immutable list of lines.
      • splitToStream

        Stream<String> splitToStream​(String value)
        Splits the given string by this type of line separator. A null value will be treated as an empty string.
        Parameters:
        value - The string to split.
        Returns:
        A stream of lines.