public static List join(Map map, String separator) {
if (map == null) {
return null;
}
List list = new ArrayList();
if (map == null || map.size() == 0) {
return list;
}
for (Map.Entry entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (value == null || value.length() == 0) {
list.add(key);
} else {
list.add(key + separator + value);
}
}
return list;
}
public static String join(List list, String separator) {
StringBuilder sb = new StringBuilder();
for (String ele : list) {
if (sb.length() > 0) {
sb.append(separator);
}
sb.append(ele);
}
return sb.toString();
}