@Override
public List<T> parse(String value) {
int idx = ParseUtils.skipSpaces(value, 0);
if (value.charAt(idx++) != '[')
throw new InvalidTypeException(String.format("cannot parse list value from \"%s\", at character %d expecting '[' but got '%c'", value, idx, value.charAt(idx)));
idx = ParseUtils.skipSpaces(value, idx);
if (value.charAt(idx) == ']')
return Collections.<T>emptyList();
List<T> l = new ArrayList<T>();
while (idx < value.length()) {
int n;
try {
n = ParseUtils.skipCQLValue(value, idx);
} catch (IllegalArgumentException e) {
throw new InvalidTypeException(String.format("Cannot parse list value from \"%s\", invalid CQL value at character %d", value, idx), e);
}
l.add(eltCodec.parse(value.substring(idx, n)));
idx = n;
idx = ParseUtils.skipSpaces(value, idx);
if (value.charAt(idx) == ']')
return l;
if (value.charAt(idx++) != ',')
throw new InvalidTypeException(String.format("Cannot parse list value from \"%s\", at character %d expecting ',' but got '%c'", value, idx, value.charAt(idx)));
idx = ParseUtils.skipSpaces(value, idx);
}
throw new InvalidTypeException(String.format("Malformed list value \"%s\", missing closing ']'", value));
}