public static List getIdsList(String ids) {
ids = StringUtils.stripStart(ids, "{");
ids = StringUtils.stripEnd(ids, "}");
List list = parseInts(ids, ',');
return list;
}
public static List parseInts(String source, char delimeter) {
if (StringUtils.isEmpty(source)) {
return Collections.emptyList();
}
List result = new ArrayList();
for (String intStr : source.split(String.valueOf(delimeter))) {
result.add(NumberUtils.toInt(intStr));
}
return result;
}
public static List parseStrings(String source, char delimiter) {
Pattern p = (delimiter == ',') ? ',' : Pattern.compile(String.valueOf(delimiter));
return Arrays.asList(p.split(source, 0));
}
Leave a Reply