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

kamil commented on COLLECTIONS-600:
-----------------------------------

Hi, is this issue still open? If yes i would like to try to contribute to it.

I have a question does the community have a preferred way how to treat 
null-safe methods? Because in my option it is open for discussion if treating  
two "null" collections as false or throwing  an exception. Yet in one 
collection there should be a one way how to treat similar issues. I was 
thinking to modify the methods so whey will  treat null as false in comparison. 
What do you thing about this approach? 

> 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
(v8.20.1#820001)

Reply via email to