Java Utililty Methods Collection to List

List of utility methods to do Collection to List

Description

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

Method

ListcollectionToList(Collection theset)
collection To List
List<E> thelist = new ArrayList<E>();
for (E obj : theset)
    thelist.add(obj);
return thelist;
ListcollectionToList(Collection source)
Creates a new List with the same contents as the given Collection.
return new ArrayList<T>(source); 
StringcollectionToList(Iterable c)
collection To List
StringBuffer ret = new StringBuffer();
for (Iterator<? extends Object> itr = c.iterator(); itr.hasNext();) {
    ret.append(itr.next().toString());
    if (itr.hasNext())
        ret.append(",");
return ret.toString();
ListconvertCollectionToList(Collection c)
Converts a collection into a list
List l = null;
if (c instanceof List) {
    l = (List) c;
} else {
    l = new ArrayList();
    l.addAll(c);
return l;
...
ListconvertCollectionToList(Collection coll)
Converts an instance of List to an instance of Collection.
if (coll instanceof List) {
    return (List<T>) coll;
} else {
    List<T> theReturn = new ArrayList<T>(coll);
    return theReturn;
ListconvertCollectionToList(Collection collection)
Methode de conversion d'une collection en Liste
if (collection == null)
    return null;
return new ArrayList<T>(collection);
ListconvertCollectionToList(final Collection collection)
convert Collection To List
if (List.class.isAssignableFrom(collection.getClass())) {
    return (List<T>) collection;
return new ArrayList<>(collection);
StringconvertCollectionToSQL(List listId)
convert Collection To SQL
String s = "";
for (Integer i : listId) {
    s += i + ",";
return s.substring(0, s.lastIndexOf(","));
ListnewList(final Collection elements)
new List
return new ArrayList<T>(elements);
ListnewList(final Collection collection)
New list.
return list(collection);