44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package org.warp.jcwdb.lists;
|
|
|
|
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
|
import org.warp.jcwdb.EnhancedObject;
|
|
import org.warp.jcwdb.database.IDatabaseTools;
|
|
import org.warp.jcwdb.annotations.DBDataType;
|
|
import org.warp.jcwdb.annotations.DBField;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class EnhancedObjectJCWDBList<T extends EnhancedObject> extends JCWDBList<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 EnhancedObjectJCWDBList() {
|
|
super();
|
|
}
|
|
|
|
public EnhancedObjectJCWDBList(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);
|
|
}
|
|
}
|