com.infomaximum.database.schema.dbstruct.DBPrefixIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rdao Show documentation
Show all versions of rdao Show documentation
Library for creating a light cluster
The newest version!
package com.infomaximum.database.schema.dbstruct;
import com.infomaximum.database.exception.SchemaException;
import com.infomaximum.database.utils.IndexUtils;
import com.infomaximum.database.utils.TypeConvert;
import net.minidev.json.JSONObject;
import java.util.List;
public class DBPrefixIndex extends DBIndex {
private final static byte[] INDEX_NAME_BYTES = TypeConvert.pack("prf");
private static final String JSON_PROP_FIELD_IDS = "field_ids";
DBPrefixIndex(int id, DBField[] fields) {
super(id, fields);
}
public DBPrefixIndex(DBField[] fields) {
this(-1, fields);
}
static DBPrefixIndex fromJson(JSONObject source, List tableFields) throws SchemaException {
return new DBPrefixIndex(
JsonUtils.getValue(JSON_PROP_ID, Integer.class, source),
IndexUtils.getFieldsByIds(tableFields, JsonUtils.getIntArrayValue(JSON_PROP_FIELD_IDS, source))
);
}
@Override
protected byte[] getIndexNameBytes() {
return INDEX_NAME_BYTES;
}
@Override
JSONObject toJson() {
JSONObject object = new JSONObject();
object.put(JSON_PROP_ID, getId());
object.put(JSON_PROP_FIELD_IDS, JsonUtils.toJsonArray(getFieldIds()));
return object;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy