public Object read(JSONReader reader, JsonParser p) throws IOException {
JsonToken t = p.getCurrentToken();
if (t == JsonToken.VALUE_NUMBER_INT) {
int ix = p.getIntValue();
if (ix < 0 || ix >= _byIndex.length) {
throw new JSONObjectException("Failed to bind Enum "+desc()+" with index "+ix
+" (has "+_byIndex.length+" values)");
}
return _byIndex[ix];
}
String id = p.getValueAsString().trim();
Object e = _byName.get(id);
if (e == null) {
throw new JSONObjectException("Failed to find Enum of type "+desc()+" for value '"+id+"'");
}
return e;
}