[ 
https://issues.apache.org/jira/browse/COLLECTIONS-600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16025260#comment-16025260
 ] 

ASF GitHub Bot commented on COLLECTIONS-600:
--------------------------------------------

GitHub user jonasholtkamp opened a pull request:

    https://github.com/apache/commons-collections/pull/22

    [COLLECTIONS-600] Null-safe implementation of 
CollectionUtils#isEqualCollection

    Other Commons `*Utils` classes as `StringUtils` etc. feature null-safe 
methods. With this Pull Request now `CollectionUtils#isEqualCollection` does, 
too.
    
    Fixes issue COLLECTIONS-600.

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

    $ git pull https://github.com/jonasholtkamp/commons-collections trunk

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

    https://github.com/apache/commons-collections/pull/22.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 #22
    
----
commit 06f64ca95ed4c3a9e3e8d376a619a7d3cb738e1c
Author: Jonas Holtkamp <[email protected]>
Date:   2017-05-25T19:17:40Z

    Null-safe implementation of CollectionUtils#isEqualCollection

----


> Make CollectionUtils (in particular isEqualCollection) null-safe
> ----------------------------------------------------------------
>
>                 Key: COLLECTIONS-600
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-600
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: Collection
>    Affects Versions: 4.1
>            Reporter: Jonas Holtkamp
>            Priority: Minor
>
> Other Commons {{*Utils}} classes as StringUtils etc. feature null-safe 
> methods. Why doesn't for example {{CollectionUtils#isEqualCollection}} 
> include a null check, like this?
> {code}    public static boolean isEqualCollection(final Collection<?> a, 
> final Collection<?> b) {
>         if(a == null || b == null) {
>             return false;
>         }
>         if(a.size() != b.size()) {
>             return false;
>         }
>         final CardinalityHelper<Object> helper = new 
> CardinalityHelper<Object>(a, b);
>         if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
>             return false;
>         }
>         for( final Object obj : helper.cardinalityA.keySet()) {
>             if(helper.freqA(obj) != helper.freqB(obj)) {
>                 return false;
>             }
>         }
>         return true;
>     }
> {code}
> I considered filing a Pull Request but wanted to ask here first.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to