Java Utililty Methods Collection Convert

List of utility methods to do Collection Convert

Description

The list of methods to do Collection Convert are organized into topic(s).

Method

double[]convert(Collection list)
convert
return convert(list.toArray(new Double[] {}));
String[]convert(Collection c)
convert
if (c == null)
    return null;
String[] r = new String[c.size()];
int i = 0;
for (String s : c) {
    r[i] = s;
    i++;
return r;
Collectionconvert2IntegerCollection(String[] strs)
convert Integer Collection
Collection result = null;
if (strs == null) {
    result = new ArrayList(0);
} else {
    result = new ArrayList(strs.length);
    for (int i = 0; i < strs.length; i++) {
        result.add(new Integer(strs[i]));
return result;
CollectionconvertArrayInCollection(String[] array)
convert Array In Collection
Collection coll = new ArrayList();
for (int i = 0; i < array.length; i++) {
    String role = array[i];
    coll.add(role);
return coll;
char[]convertCharCollectionToArray(Collection chars)
convert Char Collection To Array
final char[] array = new char[chars.size()];
int i = 0;
for (final Character c : chars) {
    array[i++] = c;
return array;
String[]convertCollectionInArray(Collection coll)
convert Collection In Array
String[] array = new String[coll.size()];
int i = 0;
for (Iterator iterator = coll.iterator(); iterator.hasNext();) {
    Object object = (Object) iterator.next();
    String role = object.toString();
    array[i] = role;
    i++;
return array;
StringconvertCollectionStringToCSV(Collection coll, boolean valueInSingleQuotes)
convert Collection String To CSV
StringBuffer sb = new StringBuffer();
int count = 1;
for (String value : coll) {
    if (valueInSingleQuotes) {
        sb.append("'");
    sb.append(value);
    if (valueInSingleQuotes) {
...
CconvertCollectionType(Iterable from, C newCollection, Class listClass)
convert Collection Type
for (Object item : from) {
    newCollection.add(listClass.cast(item));
return newCollection;
ObjectconvertToCollection(Object source)
convert To Collection
if (source == null) {
    return null;
if (source instanceof Collection) {
    return source;
return Collections.singleton(source);
StringconvertToHqlParameters(Collection numbers)
convert To Hql Parameters
StringBuilder hqlBuilder = new StringBuilder();
for (Number number : numbers) {
    if (hqlBuilder.length() > 0) {
        hqlBuilder.append(",");
    hqlBuilder.append(number);
return hqlBuilder.toString();
...