You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2012/12/13 22:56:12 UTC

[jira] [Resolved] (COLLECTIONS-436) Add a method that returns an empty collection if a passed in collection is null

     [ https://issues.apache.org/jira/browse/COLLECTIONS-436?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart resolved COLLECTIONS-436.
-----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0

Hi Arman,

thanks for your patch, the content has been applied in r1421567 together with minor changes (e.g. added to javadoc that an *immutable* empty collection/set/list/map is returned if parameter is null).

Thomas
                
> Add a method that returns an empty collection if a passed in collection is null
> -------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-436
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-436
>             Project: Commons Collections
>          Issue Type: Wish
>          Components: Collection
>            Reporter: Arman Sharif
>            Priority: Minor
>             Fix For: 4.0
>
>         Attachments: COLLECTIONS-436.patch
>
>
> Would it be possible to add methods to CollectionUtils that return an empty collection if given a {{null}}? e.g.
> {code:java}
>     public static <T> List<T> emptyIfNull(List<T> list) {
>         return list == null ? Collections.<T>emptyList() : list;
>     }
>     public static <T> Set<T> emptyIfNull(Set<T> set) {
>         return set == null ? Collections.<T>emptySet() : set;
>     }
>     public static <K,V> Map<K,V> emptyIfNull(Map<K,V> map) {
>         return map == null ? Collections.<K,V>emptyMap() : map;
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira