AmarGhugare opened a new pull request, #1869:
URL: https://github.com/apache/commons-lang/pull/1869

   Adds `StringUtils.lastIndexOfAnyBut(CharSequence, char...)` and 
`StringUtils.lastIndexOfAnyBut(CharSequence, CharSequence)` for 
[LANG-622](https://issues.apache.org/jira/browse/LANG-622), completing the 
reverse counterpart of `indexOfAnyBut`.
   
   For example, `StringUtils.lastIndexOfAnyBut("abcdd", "bd")` returns `2`, the 
index of `c`. Both overloads return `-1` for null/empty inputs or when every 
code point is in the allowed set, matching the existing forward method's 
conventions.
   
   Build the allowed code-point set once and scan the input backward, stopping 
at the first code point outside the set. Supplementary characters are compared 
as whole code points, unpaired surrogates are handled individually, and the 
result is a UTF-16 index pointing to the start of the matched code point. The 
char-array overload delegates through `CharBuffer` to keep the two overloads 
consistent.
   
   Tests cover normal use, repeated suffixes, duplicates in the search set, 
null/empty values, varargs, non-ASCII characters, supplementary code points 
sharing either surrogate half, unpaired surrogates, and 
StringBuilder/CharBuffer/custom CharSequence inputs. A guarded CharSequence 
test verifies that the implementation searches backward and stops before 
reading an unnecessary prefix.
   
   Focused validation: all 165 StringUtilsEqualsIndexOfTest invocations passed. 
Full default Maven validation (`mvn -o -B -ntp`, cached dependencies) passed 
with JDK 25.0.4.1 and release 8: 108,576 tests, zero failures/errors, 18 
skipped. Coverage, RAT, Checkstyle, Japicmp, SpotBugs, PMD and Javadoc passed. 
`git diff --check` passed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to