All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tw.go.plugin.util.ListUtil Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
package com.tw.go.plugin.util;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ListUtil {
    public static boolean isEmpty(List list) {
        return list == null || list.isEmpty();
    }

    public static String join(Collection c) {
        return join(c, ", ");
    }

    public static String join(Collection c, String join) {
        StringBuffer sb = new StringBuffer();
        for (Iterator iter = c.iterator(); iter.hasNext(); ) {
            sb.append(iter.next());
            if (iter.hasNext()) {
                sb.append(join);
            }
        }
        return sb.toString();
    }

    public static String[] toArray(List args) {
        return args.toArray(new String[args.size()]);
    }
}