Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1182

Clarify JavaDoc of StringUtils.containsAny()

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.4
    • 3.5
    • lang.*
    • None

    Description

      (1) The javadoc for StringUtils.containsAny(CharSequence cs, CharSequence... searchCharSequences) confusingly says

      • StringUtils.containsAny("abcd", "ab", "cd") = false

      You can verify this actually returns true by running this:

      if (!StringUtils.containsAny("abcd", "ab", "cd"))
      throw new AssertionError("Third sample from StringUtils 3.4 javadoc");

      (2) The javadoc for containsAny(final CharSequence cs, final CharSequence searchChars) is inadequate, and could easily mislead naive readers to believe this containsAny() looks for a matching sequence (substring) rather than characters in a set:

      • StringUtils.containsAny("zzabyycdxx", "za") = true
      • StringUtils.containsAny("zzabyycdxx", "by") = true

      In other words, both examples would be equally true for StringUtils.contains(). I suggest adding clarifying examples, like:

      • StringUtils.containsAny("zzabyycdxx", "\tx") = true
      • StringUtils.containsAny("zzabyycdxx", "$.#yF") = true

      Attachments

        Activity

          larry_west Larry West created issue -
          githubbot ASF GitHub Bot added a comment -

          GitHub user PascalSchumacher opened a pull request:

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

          LANG-1182: adding clarifying examples to StringUtils#containsAny javadoc

          as suggested by Larry West in https://issues.apache.org/jira/browse/LANG-1182

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

          $ git pull https://github.com/PascalSchumacher/commons-lang LANG-1182

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

          https://github.com/apache/commons-lang/pull/114.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 #114


          commit 1260e09d6f2314c7099d061f1c65e6b4275cb8a1
          Author: Pascal Schumacher <pascalschumacher@gmx.net>
          Date: 2015-11-08T21:44:07Z

          LANG-1182: adding clarifying examples to StringUtils#containsAny javadoc

          as suggested by Larry West in https://issues.apache.org/jira/browse/LANG-1182


          githubbot ASF GitHub Bot added a comment - GitHub user PascalSchumacher opened a pull request: https://github.com/apache/commons-lang/pull/114 LANG-1182 : adding clarifying examples to StringUtils#containsAny javadoc as suggested by Larry West in https://issues.apache.org/jira/browse/LANG-1182 You can merge this pull request into a Git repository by running: $ git pull https://github.com/PascalSchumacher/commons-lang LANG-1182 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-lang/pull/114.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 #114 commit 1260e09d6f2314c7099d061f1c65e6b4275cb8a1 Author: Pascal Schumacher <pascalschumacher@gmx.net> Date: 2015-11-08T21:44:07Z LANG-1182 : adding clarifying examples to StringUtils#containsAny javadoc as suggested by Larry West in https://issues.apache.org/jira/browse/LANG-1182
          britter Benedikt Ritter made changes -
          Field Original Value New Value
          Summary javadoc correction, clarification on 2 variants of StringUtils.containsAny() Clarify JavaDoc of StringUtils.containsAny()
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

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

          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/commons-lang/pull/114
          britter Benedikt Ritter made changes -
          Fix Version/s 3.5 [ 12331955 ]
          commit 56907c9a96a50af44415111fcea3e76ce4d1890f
          Merge: 4811375 7f0d6b4
          Author: Benedikt Ritter <britter@apache.org>
          Date:   Mon Nov 16 20:16:52 2015 +0100
          
              Merge branch 'LANG-1182'
          
              LANG-1182: Clarify JavaDoc of StringUtils.containsAny(). Thanks to
              Larry West for the suggestion and to Pascal Schuhmacher for implementing
              it. This fixes #114 from github.
          
          britter Benedikt Ritter added a comment - commit 56907c9a96a50af44415111fcea3e76ce4d1890f Merge: 4811375 7f0d6b4 Author: Benedikt Ritter <britter@apache.org> Date: Mon Nov 16 20:16:52 2015 +0100 Merge branch 'LANG-1182' LANG-1182: Clarify JavaDoc of StringUtils.containsAny(). Thanks to Larry West for the suggestion and to Pascal Schuhmacher for implementing it. This fixes #114 from github.
          britter Benedikt Ritter made changes -
          Assignee Benedikt Ritter [ britter ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          britter Benedikt Ritter made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

          People

            britter Benedikt Ritter
            larry_west Larry West
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified