commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COLLECTIONS-600) Make CollectionUtils (in particular isEqualCollection) null-safe
Date Wed, 24 May 2017 09:42:04 GMT

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

Bruno P. Kinoshita commented on COLLECTIONS-600:
------------------------------------------------

Valid question. I wouldn't know to say whether two collections that are `null` are equals
or not. But definitely worth raising this issue in the [commons dev mailing list](https://commons.apache.org/mail-lists.html)
(just use the prefix [collections] when posting).

Cheers
Bruno

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

Mime
View raw message