strangedb/src/main/java/it/cavallium/strangedb/lists/ObjectStrandeDbList.java

39 lines
952 B
Java

package it.cavallium.strangedb.lists;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.cavallium.strangedb.database.IDatabaseTools;
import it.cavallium.strangedb.annotations.DbDataType;
import it.cavallium.strangedb.annotations.DbField;
import java.io.IOException;
public class ObjectStrandeDbList<T> extends StrandeDbList<T> {
@DbField(id = 0, type = DbDataType.REFERENCES_LIST)
private LongArrayList indices;
@Override
protected LongArrayList getIndices() {
return indices;
}
public ObjectStrandeDbList() {
super();
}
public ObjectStrandeDbList(IDatabaseTools databaseTools) throws IOException {
super(databaseTools);
indices = new LongArrayList();
}
@Override
protected T loadItem(long uid) throws IOException {
return databaseTools.getObjectsIO().loadObject(uid);
}
@Override
protected void writeItemToDisk(long uid, T item) throws IOException {
databaseTools.getObjectsIO().setObject(uid, item);
}
}