You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by rikles <gi...@git.apache.org> on 2015/10/05 15:06:56 UTC

[GitHub] commons-lang pull request: LANG-1171 Add null safe compare methods...

GitHub user rikles opened a pull request:

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

    LANG-1171 Add null safe compare methods in StringUtils :

    Add null safe methods in `StringUtils` to compare 2 Strings :
    ```java
    public static int compare(final String str1, final String str2);
    public static int compare(final String str1, final String str2, final boolean nullIsLess);
    public static int compareIgnoreCase(final String str1, final String str2);
    public static int compareIgnoreCase(final String str1, final String str2, final boolean nullIsLess);
    ```
    Those methods are null safe equivalent to :
    ```java
    str1.compareTo(str2);
    str1.compareToIgnoreCase(str2);
    ```

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

    $ git pull https://github.com/rikles/commons-lang fix-LANG-1171

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

    https://github.com/apache/commons-lang/pull/110.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 #110
    
----
commit 94ec5a11122b2e60fbffcc35373c978c839bf8ae
Author: Loic Guibert <lf...@yahoo.fr>
Date:   2015-10-05T13:00:50Z

    LANG-1171 Add null safe compare methods in StringUtils :
      - StringUtils.compare(String str1, String str2);
      - StringUtils.compare(String str1, String str2, boolean nullIsLess);
      - StringUtils.compareIgnoreCase(String str1, String str2);
      - StringUtils.compareIgnoreCase(String str1, String str2, boolean nullIsLess);

----


---
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: LANG-1171 Add null safe compare methods...

Posted by rikles <gi...@git.apache.org>.
Github user rikles commented on the pull request:

    https://github.com/apache/commons-lang/pull/110#issuecomment-145528980
  
    This unit test fails :
    ```
    org.apache.commons.lang3.StringUtilsTest.testStringUtilsCharSequenceContract()
    ```
    
    It said :
    > The method public static int org.apache.commons.lang3.StringUtils.compare(String,String,boolean) appears to be immutable in spirit and therefore must not accept a String
    
    I use String parameters instead of CharSequence because in the Java conception, only String are Comparable and not CharSequence.
    I call `String#compareTo(String)` in the implementation.
    
    So what should I do ?


---
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: LANG-1171 Add null safe compare methods...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


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