@Override
public Range<?> decode(Type type, Short typeLength, Integer typeModifier, CharSequence buffer, Context context) throws IOException {
RangeType rangeType = (RangeType) type;
Type baseType = rangeType.getBase();
boolean lowerInc = false, upperInc = false;
Object lower = null, upper = null;
if (buffer.charAt(0) == '[') {
lowerInc = true;
}
if (buffer.charAt(buffer.length() - 1) == ']') {
upperInc = true;
}
CharSequence lowerTxt = buffer.subSequence(1, findBound(buffer, 1));
if (lowerTxt.length() != 0) {
lower = baseType.getTextCodec().decoder.decode(baseType, null, null, lowerTxt, context);
}
CharSequence upperTxt = buffer.subSequence(2 + lowerTxt.length(), buffer.length() - 1);
if (upperTxt.length() != 0) {
upper = baseType.getTextCodec().decoder.decode(baseType, null, null, upperTxt, context);
}
return Range.create(lower, lowerInc, upper, upperInc);
}