This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 954338a1522aa32b869966be63ef833d10cdd79e Author: Gary Gregory <[email protected]> AuthorDate: Wed Jul 1 17:07:09 2020 -0400 Sort 2 methods. --- .../java/org/apache/commons/lang3/StringUtils.java | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 6778720..0cb10e6 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -8635,41 +8635,35 @@ public class StringUtils { * * <p>A {@code null} string input will return {@code null}. * An empty ("") string input will return the empty string. - * An empty or {@code null} separator will return the empty string if - * the input string is not {@code null}.</p> * * <p>If nothing is found, the empty string is returned.</p> * * <pre> * StringUtils.substringAfterLast(null, *) = null * StringUtils.substringAfterLast("", *) = "" - * StringUtils.substringAfterLast(*, "") = "" - * StringUtils.substringAfterLast(*, null) = "" - * StringUtils.substringAfterLast("abc", "a") = "bc" - * StringUtils.substringAfterLast("abcba", "b") = "a" - * StringUtils.substringAfterLast("abc", "c") = "" - * StringUtils.substringAfterLast("a", "a") = "" - * StringUtils.substringAfterLast("a", "z") = "" + * StringUtils.substringAfterLast("abc", 'a') = "bc" + * StringUtils.substringAfterLast(" bc", 32) = "bc" + * StringUtils.substringAfterLast("abcba", 'b') = "a" + * StringUtils.substringAfterLast("abc", 'c') = "" + * StringUtils.substringAfterLast("a", 'a') = "" + * StringUtils.substringAfterLast("a", 'z') = "" * </pre> * * @param str the String to get a substring from, may be null * @param separator the String to search for, may be null * @return the substring after the last occurrence of the separator, * {@code null} if null String input - * @since 2.0 + * @since 3.11 */ - public static String substringAfterLast(final String str, final String separator) { + public static String substringAfterLast(final String str, final int separator) { if (isEmpty(str)) { return str; } - if (isEmpty(separator)) { - return EMPTY; - } final int pos = str.lastIndexOf(separator); - if (pos == INDEX_NOT_FOUND || pos == str.length() - separator.length()) { + if (pos == INDEX_NOT_FOUND || pos == str.length() - 1) { return EMPTY; } - return str.substring(pos + separator.length()); + return str.substring(pos + 1); } /** @@ -8678,35 +8672,41 @@ public class StringUtils { * * <p>A {@code null} string input will return {@code null}. * An empty ("") string input will return the empty string. + * An empty or {@code null} separator will return the empty string if + * the input string is not {@code null}.</p> * * <p>If nothing is found, the empty string is returned.</p> * * <pre> * StringUtils.substringAfterLast(null, *) = null * StringUtils.substringAfterLast("", *) = "" - * StringUtils.substringAfterLast("abc", 'a') = "bc" - * StringUtils.substringAfterLast(" bc", 32) = "bc" - * StringUtils.substringAfterLast("abcba", 'b') = "a" - * StringUtils.substringAfterLast("abc", 'c') = "" - * StringUtils.substringAfterLast("a", 'a') = "" - * StringUtils.substringAfterLast("a", 'z') = "" + * StringUtils.substringAfterLast(*, "") = "" + * StringUtils.substringAfterLast(*, null) = "" + * StringUtils.substringAfterLast("abc", "a") = "bc" + * StringUtils.substringAfterLast("abcba", "b") = "a" + * StringUtils.substringAfterLast("abc", "c") = "" + * StringUtils.substringAfterLast("a", "a") = "" + * StringUtils.substringAfterLast("a", "z") = "" * </pre> * * @param str the String to get a substring from, may be null * @param separator the String to search for, may be null * @return the substring after the last occurrence of the separator, * {@code null} if null String input - * @since 3.11 + * @since 2.0 */ - public static String substringAfterLast(final String str, final int separator) { + public static String substringAfterLast(final String str, final String separator) { if (isEmpty(str)) { return str; } + if (isEmpty(separator)) { + return EMPTY; + } final int pos = str.lastIndexOf(separator); - if (pos == INDEX_NOT_FOUND || pos == str.length() - 1) { + if (pos == INDEX_NOT_FOUND || pos == str.length() - separator.length()) { return EMPTY; } - return str.substring(pos + 1); + return str.substring(pos + separator.length()); } // SubStringAfter/SubStringBefore
