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

StringtoSeparatedString(Collection items, String separator)
Convert a collection of items to a string separated by a specified string
return toSeparatedString(items.toArray(new Object[items.size()]), separator);
StringtoSeperatedString(final Collection list)
to Seperated String
final StringBuffer stringBuffer = new StringBuffer();
for (final T element : list) {
    if (stringBuffer.length() != 0)
        stringBuffer.append(",");
    stringBuffer.append(element.toString());
return stringBuffer.toString();
SettoSet(Collection c)
to Set
return asSet(c);
TtoSingleton(Collection l)
to Singleton
return toSingleton(l.iterator());
StringtoSQLIn(Collection values)
to SQL In
if (values == null || values.isEmpty())
    return null;
String[] strvalues = new String[0];
strvalues = (String[]) values.toArray(new String[values.size()]);
return toSQLIn(strvalues);
StringBuildertoStringBuilder(Collection collection, String delimiter)
Transform a collection of objects to a delimited String.
StringBuilder sb = new StringBuilder(collection.size() * 20);
for (Iterator<? extends Object> it = collection.iterator(); it.hasNext();) {
    Object cs = it.next();
    sb.append(cs);
    if (it.hasNext()) {
        sb.append(delimiter);
return sb;
ListtoStringColl(Collection set)
to String Coll
List<String> list = new ArrayList<String>();
toStringColl(list, set);
return list;
StringtoSV(Collection collection, String separator)
to SV
if (collection == null) {
    return null;
StringBuilder sb = new StringBuilder();
Iterator itr = collection.iterator();
while (itr.hasNext()) {
    sb.append(itr.next());
    if (itr.hasNext()) {
...
Object[][]toTestParameters(Collection rawParams)
to Test Parameters
Object[][] testParams = new Object[rawParams.size()][];
int counter = 0;
for (Object curRawParam : rawParams)
    testParams[counter++] = new Object[] { curRawParam };
return testParams;
StringtoToolTip(final Collection collection)
to Tool Tip
if (collection == null || collection.size() == 0) {
    return null;
final String START_SEPARATOR = "<p>"; 
final String END_SEPARATOR = "</p>"; 
final StringBuffer buffer = new StringBuffer("<html>"); 
for (Iterator<?> iterator = collection.iterator(); iterator.hasNext();) {
    buffer.append(START_SEPARATOR);
...