code: private static void validateLineBreaks(int[] linebreaks, int textLength) {
          int prev = 0;
          for (int i = 0; i < linebreaks.length; ++i) {
              int next = linebreaks[i];
              if (next <= prev) {
                  throw new IllegalArgumentException("bad linebreak: " + next + " at index: " + i);
              }
              prev = next;
          }
          if (prev != textLength) {
              throw new IllegalArgumentException("last linebreak must be at " + textLength);
          }
      }
docs: Throw exception if line breaks array is invalid.