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

44 lines
1.1 KiB
Java

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