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

    https://github.com/apache/commons-lang/pull/137#discussion_r62429807
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -460,6 +460,108 @@ 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) = ""
    +     * </pre>
    +     *
    +     * @param str  the String to check, may be null
    +     * @param maxWidth  maximum length of result String, must be positive
    +     * @return truncated String, {@code null} if null String input
    +     * @since 4.0
    --- End diff --
    
    I guess this should be `3.5`?


---
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