You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Maarten Coene (JIRA)" <ji...@apache.org> on 2008/11/17 14:32:46 UTC

[jira] Created: (LANG-470) Add containsAll methods to ArrayUtils

Add containsAll methods to ArrayUtils
-------------------------------------

                 Key: LANG-470
                 URL: https://issues.apache.org/jira/browse/LANG-470
             Project: Commons Lang
          Issue Type: New Feature
    Affects Versions: 2.4
            Reporter: Maarten Coene


The ArrayUtils class contains several "contains" methods.
It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Hasan Diwan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hasan Diwan updated LANG-470:
-----------------------------

    Attachment: ArrayUtilsContainsAll.pat

Adds the requested methods to ArrayUtils

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12798543#action_12798543 ] 

Henri Yandell commented on LANG-470:
------------------------------------

The reason (along with LANG-238) is that reimplementing all of the Set /Collection interface as Array methods is not the best use of ArrayUtils.

Having a way to get to the Set API might be desirable - options would seem to be:

* An asSet method that returns a HashSet using the above (with null protection).
* An asSet method that returns an ArraySet (might be value in this).
* Additionally a null protected asList could be added to handle your NPE comment and would be reused if the HashSet option is chosen.

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795274#action_12795274 ] 

Henri Yandell commented on LANG-470:
------------------------------------

Pasted example code for ArraySet into LANG-238. I think that would be a better way to implement this; with the issue on our side of overlap between Collections and Lang.

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12798568#action_12798568 ] 

Paul Benedict commented on LANG-470:
------------------------------------

Why not wrap the array into a List and use Collections on it? We should not make Array methods that duplicate Collections class methods.

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-470:
-------------------------------

    Fix Version/s:     (was: 3.0)
                   3.1

No backwards compat issues, so moving to 3.1. If resolved before 3.0 is released please assign to 3.0. 

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.1
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12782814#action_12782814 ] 

Henri Yandell commented on LANG-470:
------------------------------------

Still unsure how to handle edge cases.

This is effectively a set method on arrays, so I'm thinking more in the direction of adding a Set<T> ArrayUtils.toSet(T[]) method. It would mean a, potentially non-public, ArraySet class.

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12729549#action_12729549 ] 

Henri Yandell commented on LANG-470:
------------------------------------

Thanks for the patch Hasan. 

The patch has array1 and array2 backwards I think. It should be array2 in array1, rather than array1 in array2. 

Need to decide what containsAll( array, null ) would mean. Is that a true? If it is, what does containsAll( null, null ) mean?

Also need to add some tests. 

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-470:
-------------------------------

    Fix Version/s: 3.0

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-470.
------------------------------

    Resolution: Won't Fix

Closing as WONTFIX.

Too easy to do:

new HashSet<Integer>(Arrays.asList(array1)).containsAll(Arrays.asList(array2))

Primitives aren't supported, but I think the solution there would be to turn to a primitive handling Set class.

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (LANG-470) Add containsAll methods to ArrayUtils

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene reopened LANG-470:
--------------------------------


Sorry but I don't agree on this one.

If the code you provided is the reason to not implement his, you should remove a lot of other utility methods as well from ArrayUtils and other *Utils classes.
In addition, your code will throw a NPE if one of the passed in arrays are null. The "one-line code" becomes a bit more complex to handle this situation properly.

Maarten

> Add containsAll methods to ArrayUtils
> -------------------------------------
>
>                 Key: LANG-470
>                 URL: https://issues.apache.org/jira/browse/LANG-470
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Maarten Coene
>             Fix For: 3.0
>
>         Attachments: ArrayUtilsContainsAll.pat
>
>
> The ArrayUtils class contains several "contains" methods.
> It could be usefull to add the corresponding containsAll(Object[] array1, Object[] array2) methods (and corresponding for primitive types).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.