in src/main/user-impl/java/com/mysql/cj/xdevapi/CreateIndexParams.java [202:280]
public IndexField(DbDoc indexField) {
for (String key : indexField.keySet()) {
if (!TYPE.equals(key) && !FIELD.equals(key) && !REQUIRED.equals(key) && !OPTIONS.equals(key) && !SRID.equals(key) && !ARRAY.equals(key)) {
throw new XDevAPIError("The '" + key + "' field is not allowed in indexField.");
}
}
JsonValue val = indexField.get(FIELD);
if (val != null) {
if (val instanceof JsonString) {
this.field = ((JsonString) val).getString();
} else {
throw new XDevAPIError("Index field 'field' member must be a string.");
}
} else {
throw new XDevAPIError("Index field definition has no document path.");
}
val = indexField.get(TYPE);
if (val != null) {
if (val instanceof JsonString) {
this.type = ((JsonString) val).getString();
// TODO pure "TEXT" is not allowed as a type, server requires the length specification
// we're waiting for clarification about whether we set some default on client side in that case, eg.:
// if ("TEXT".equals(this.type)) {this.type = "TEXT(64)";}
// or we do nothing and user has to specify TEXT(n) always
} else {
throw new XDevAPIError("Index type must be a string.");
}
} else {
throw new XDevAPIError("Index field definition has no field type.");
}
val = indexField.get(REQUIRED);
if (val != null) {
if (val instanceof JsonLiteral && !JsonLiteral.NULL.equals(val)) {
this.required = Boolean.valueOf(((JsonLiteral) val).value);
} else {
throw new XDevAPIError("Index field 'required' member must be boolean.");
}
} else if (GEOJSON.equalsIgnoreCase(this.type)) {
this.required = Boolean.TRUE;
}
val = indexField.get(OPTIONS);
if (val != null) {
if (GEOJSON.equalsIgnoreCase(this.type)) {
if (val instanceof JsonNumber) {
this.options = ((JsonNumber) val).getInteger();
} else {
throw new XDevAPIError("Index field 'options' member must be integer.");
}
} else {
throw new XDevAPIError("Index field 'options' member should not be used for field types other than GEOJSON.");
}
}
val = indexField.get(SRID);
if (val != null) {
if (GEOJSON.equalsIgnoreCase(this.type)) {
if (val instanceof JsonNumber) {
this.srid = ((JsonNumber) val).getInteger();
} else {
throw new XDevAPIError("Index field 'srid' member must be integer.");
}
} else {
throw new XDevAPIError("Index field 'srid' member should not be used for field types other than GEOJSON.");
}
}
val = indexField.get(ARRAY);
if (val != null) {
if (val instanceof JsonLiteral && !JsonLiteral.NULL.equals(val)) {
this.array = Boolean.valueOf(((JsonLiteral) val).value);
} else {
throw new XDevAPIError("Index field 'array' member must be boolean.");
}
}
}