Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/137#discussion_r65716762
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -460,6 +460,118 @@ public static String trimToEmpty(final String str) {
             return str == null ? EMPTY : str.trim();
         }
     
    +    /**
    +     * <p>Truncates a String. This will turn
    +     * "Now is the time for all good men" into "Now is the time for"</p>
    +     *
    +     * <p>Specifically:</p>
    +     * <ul>
    +     *   <li>If {@code str} is less than {@code maxWidth} characters
    +     *       long, return it.</li>
    +     *   <li>Else truncate it to {@code (substring(str, 0, 
maxWidth))}.</li>
    +     *   <li>If {@code maxWidth} is less than {@code 0}, throw an
    +     *       {@code IllegalArgumentException}.</li>
    +     *   <li>In no case will it return a String of length greater than
    +     *       {@code maxWidth}.</li>
    +     * </ul>
    +     *
    +     * <pre>
    +     * StringUtils.truncate(null, *)      = null
    +     * StringUtils.truncate("", 4)        = ""
    +     * StringUtils.truncate("abcdefg", 4) = "abcd"
    +     * StringUtils.truncate("abcdefg", 6) = "abcdef"
    +     * StringUtils.truncate("abcdefg", 7) = "abcdefg"
    +     * StringUtils.truncate("abcdefg", 8) = "abcdefg"
    +     * StringUtils.truncate("abcdefg", -1) = ""
    --- End diff --
    
    This now causes an `IllegalArgumentException`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to