You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by qxo <gi...@git.apache.org> on 2017/06/29 12:55:49 UTC

[GitHub] commons-lang pull request #273: add lastIndexOfAnyChar method just like inde...

GitHub user qxo opened a pull request:

    https://github.com/apache/commons-lang/pull/273

    add lastIndexOfAnyChar method just like indexOfAny

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/qxo/commons-lang master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/273.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #273
    
----
commit 67dcca991c14c0a8b4e59c83a76b9f7cf8309a64
Author: qxo <49...@qq.com>
Date:   2017-06-29T12:52:27Z

    add lastIndexOfAnyChar

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    
    [![Coverage Status](https://coveralls.io/builds/12253598/badge)](https://coveralls.io/builds/12253598)
    
    Coverage decreased (-0.008%) to 95.164% when pulling **68e41b1cf3270a2185e93f2eb86ad93f82bde6e1 on qxo:master** into **5f0d8127579c1ce73f21daa509271c14af78b143 on apache:master**.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    @Abrasha  Thank you very much for the offer, but I think you should give @qxo some more time (a few days) to fix it himself.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by qxo <gi...@git.apache.org>.
Github user qxo commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    ok, I'll check it :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #273: add lastIndexOfAnyChar method just like inde...

Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/273#discussion_r161278687
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -2122,6 +2122,81 @@ public static int indexOfAny(final CharSequence cs, final String searchChars) {
             return indexOfAny(cs, searchChars.toCharArray());
         }
     
    +    /**
    +     * <p>Search a CharSequence to find the last index of any
    +     * character in the given set of characters.</p>
    +     *
    +     * <p>A {@code null} String will return {@code -1}.
    +     * A {@code null} search string will return {@code -1}.</p>
    +     *
    +     * <pre>
    +     * StringUtils.lastIndexOfAnyChar(null, *)            = -1
    +     * StringUtils.lastIndexOfAnyChar("", *)              = -1
    +     * StringUtils.lastIndexOfAnyChar(*, null)            = -1
    +     * StringUtils.lastIndexOfAnyChar(*, "")              = -1
    +     * StringUtils.lastIndexOfAnyChar("zzabyycdxx", "za") = 2
    +     * StringUtils.lastIndexOfAnyChar("zzabyycdxx", "by") = 5
    +     * StringUtils.lastIndexOfAnyChar("ab", 'a')          = 0
    +     * StringUtils.lastIndexOfAnyChar("ab", 'b')          = 1
    +     * StringUtils.lastIndexOfAnyChar("aba","z")          = -1
    +     * </pre>
    +     *
    +     * @param cs  the CharSequence to check, may be null
    +     * @param searchChars  the chars to search for, may be null
    +     * @return the last index of any of the chars, -1 if no match or null input
    +     */
    +     public static int lastIndexOfAnyChar( final CharSequence cs,final String searchChars) {
    +        return searchChars == null ? INDEX_NOT_FOUND : lastIndexOfAnyChar(cs,searchChars.toCharArray());
    +    }
    +
    +   /**
    +     * <p>Search a CharSequence to find the last index of any
    +     * character in the given set of characters.</p>
    +     *
    +     * <p>A {@code null} String will return {@code -1}.
    +     * A {@code null} or zero length search array will return {@code -1}.</p>
    +     *
    +     * <pre>
    +     * StringUtils.lastIndexOfAnyChar(null, *)                = -1
    +     * StringUtils.lastIndexOfAnyChar("", *)                  = -1
    +     * StringUtils.lastIndexOfAnyChar(*, null)                = -1
    +     * StringUtils.lastIndexOfAnyChar(*, [])                  = -1
    +     * StringUtils.lastIndexOfAnyChar("zzabyycdxx",['z','a']) = 2
    +     * StringUtils.lastIndexOfAnyChar("zzabyycdxx",['b','y']) = 5
    +     * StringUtils.lastIndexOfAnyChar("aba", ['z'])           = -1
    +     * </pre>
    +     *
    +     * @param cs  the CharSequence to check, may be null
    +     * @param searchChars  the chars to search for, may be null
    +     * @return the last index of any of the chars, -1 if no match or null input
    +     */
    +    public static int lastIndexOfAnyChar( final CharSequence cs,final char... searchChars) {
    --- End diff --
    
    Fix formatting.


---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by Abrasha <gi...@git.apache.org>.
Github user Abrasha commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    @PascalSchumacher will it be okay if I will fix warnings for the author?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    Thanks for the pull request, but the build fails because of checkstyle violations, see: https://travis-ci.org/apache/commons-lang/jobs/248359934 for details.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #273: add lastIndexOfAnyChar method just like inde...

Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/273#discussion_r161278859
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -2122,6 +2122,81 @@ public static int indexOfAny(final CharSequence cs, final String searchChars) {
             return indexOfAny(cs, searchChars.toCharArray());
         }
     
    +    /**
    +     * <p>Search a CharSequence to find the last index of any
    --- End diff --
    
    Use the active voice in Javadoc: "Returns...", "Searches...", "Gets..." and so on.


---

[GitHub] commons-lang issue #273: add lastIndexOfAnyChar method just like indexOfAny

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/273
  
    @Abrasha You can create a pull request for @qxo fork. If he merges it, it will be added to this pull request.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #273: add lastIndexOfAnyChar method just like inde...

Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/273#discussion_r161279018
  
    --- Diff: src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java ---
    @@ -379,6 +379,44 @@ public void testIndexOfAny_StringCharArray() {
             assertEquals(-1, StringUtils.indexOfAny("ab", 'z'));
         }
     
    +    @Test
    +    public void testLastIndexOfAny_StringCharArray() {
    +        assertEquals(-1, StringUtils.lastIndexOfAnyChar(null, (char[]) null));
    --- End diff --
    
    Maybe use INDEX_NOT_FOUND as a static import instead of -1...


---