Class Newlines


  • public final class Newlines
    extends Object
    Utility class for Newline.
    Since:
    8.2.0
    • Method Detail

      • map

        public static NewlineProcessor map​(NewlineProcessor processor,
                                           UnaryOperator<String> mapper)
        Creates a newline processor that behaves like the given 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:
        processor - The processor to wrap.
        mapper - The mapper to apply.
        Returns:
        A newline processor that behaves like the given processor, but maps each line using the given mapper.
      • newlineAsSeparator

        public static NewlineProcessor newlineAsSeparator​(Iterable<? extends Newline> newlines)
        Creates a newline processor that interprets the newlines as a separator. See Newline.asSeparator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        newlines - The newlines.
        Returns:
        A newline processor that interprets the newlines as a separator.
      • newlineAsSeparator

        public static NewlineProcessor newlineAsSeparator​(Newline... newlines)
        Creates a newline processor that interprets the newlines as a separator. See Newline.asSeparator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        newlines - The newlines.
        Returns:
        A newline processor that interprets the newlines as a separator.
      • newlineAsTerminator

        public static NewlineProcessor newlineAsTerminator​(Iterable<? extends Newline> newlines)
        Creates a newline processor that interprets the newlines as a terminator. See Newline.asTerminator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        newlines - The newlines.
        Returns:
        A newline processor that interprets the newlines as a terminator.
      • newlineAsTerminator

        public static NewlineProcessor newlineAsTerminator​(Newline... newlines)
        Creates a newline processor that interprets the newlines as a terminator. See Newline.asTerminator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        newlines - The newlines.
        Returns:
        A newline processor that interprets the newlines as a terminator.
      • newlineFiltering

        public static NewlineProcessor newlineFiltering​(NewlineProcessor processor,
                                                        Predicate<? super String> filter)
        Creates a newline processor that behaves like the given 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:
        processor - The processor to wrap.
        filter - The filter to apply.
        Returns:
        A newline processor that behaves like the given processor, but filters out lines that do not match the
      • newlineOfToken

        public static Newline newlineOfToken​(String token)
      • newlineTokenAsSeparator

        public static NewlineProcessor newlineTokenAsSeparator​(String... tokens)
        Creates a newline processor that interprets the newlines as a separator. See Newline.asSeparator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        tokens - The string tokens that represents the newlines, e.g. "\n" for Unix newlines.
        Returns:
        A newline processor that interprets the newlines as a separator.
      • newlineTokenAsSeparator

        public static NewlineProcessor newlineTokenAsSeparator​(Iterable<String> tokens)
        Creates a newline processor that interprets the newlines as a separator. See Newline.asSeparator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        tokens - The string tokens that represents the newlines, e.g. "\n" for Unix newlines.
        Returns:
        A newline processor that interprets the newlines as a separator.
      • newlineTokenAsTerminator

        public static NewlineProcessor newlineTokenAsTerminator​(Iterable<String> tokens)
        Creates a newline processor that interprets the newlines as a terminator. See Newline.asTerminator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        tokens - The string tokens that represents the newlines, e.g. "\n" for Unix newlines.
        Returns:
        A newline processor that interprets the newlines as a terminator.
      • newlineTokenAsTerminator

        public static NewlineProcessor newlineTokenAsTerminator​(String... tokens)
        Creates a newline processor that interprets the newlines as a terminator. See Newline.asTerminator() for more information. Splits line on any of the given tokens, formats using the first token.
        Parameters:
        tokens - The string tokens that represents the newlines, e.g. "\n" for Unix newlines.
        Returns:
        A newline processor that interprets the newlines as a terminator.