commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@gmail.com>
Subject Re: [lang]
Date Thu, 20 Jun 2013 15:13:50 GMT
Hi Thomas,
  A few points:
 - you correctly prefixed your email [lang], but it would have been nice to
have a bit more detail in the subject
 - enhancement requests and patches should be handled through the ASF JIRA
instance
 - java.util.Arrays.asList() is the typically recognized way to create a
list from an array.  The null safety is not a big enough concern to warrant
adding this to [lang] IMO.  However, at worst I would say the [lang]
version of this would be ArrayUtils.asList(T...), include the null check,
and delegate to Arrays.asList()

Thanks for your interest,
Matt


On Thu, Jun 20, 2013 at 4:25 AM, Thomas Lionel SMETS (prof) <
tsmets@a3-system.eu> wrote:

>  Hello,
> I have been looking for a method allowing me to convert a String[] into a
> List.
> As I could not find it on ArrayUtils, here is a small piece of code I
> wrote :
>
>     /**
>      * Converts a <code>String[]</code> into a <code>List</code>.
>      * @param array the <code>String[]</code> to convert.
>      * @return <code>null</code> if the reference provided is
> <code>null</code>, otherwise a <code>List</code> with the content
of the
> array's elements.
>      */
>     public static List<String> convertArrayToList(String[] array)
>     {
>         if (array==null)
>             return null;
>
>         List<String> list = new ArrayList<String>(array.length);
>         for (int i = 0; i < array.length; i++) {
>             list.add(array[i]);
>         }
>
>         return list;
>     }
>
> This is provided "as is" under the following licence :
> http://www.apache.org/licenses/
>
> Enjoy,
>
> \T,
>
>
> --
> Thomas Lionel SMETS, CISSP (385434)
> *m :* +32 497 44 68 12
> *ph :* +32 2 852 3341
> *skype :* thomas.lionel.smets
>
> PGP = FDF0 8FB8 4F37 3F79 1011 05AB 0DCE 9BAB 5DD0 0E10
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message