public class SpiltStringUtils {
public static <T> List<T> strToList(String str, Class<T> cls) {
List<T> res = new ArrayList<>();
if (StringUtils.isBlank(str)) {
return res;
}
for (String s : str.split(",")) {
try {
T obj = JSON.parseObject(s, cls);
res.add(obj);
} catch (Exception ignored) {
}
}
return res;
}
public static <T> List<T> strToListSeparator(String str, String separator, Class<T> cls) {
List<T> res = new ArrayList<>();
if (StringUtils.isBlank(str)) {
return res;
}
for (String s : str.split(separator)) {
try {
T obj = JSON.parseObject(s, cls);
res.add(obj);
} catch (Exception ignored) {
}
}
return res;
}
}