strangedb/src/main/java/org/warp/cowdb/lists/EnhancedObjectCowList.java

49 lines
1.1 KiB
Java

package org.warp.cowdb.lists;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import org.warp.cowdb.EnhancedObject;
import org.warp.cowdb.IDatabase;
import org.warp.jcwdb.ann.DBDataType;
import org.warp.jcwdb.ann.DBField;
import java.io.IOException;
public class EnhancedObjectCowList<T extends EnhancedObject> extends CowList<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 EnhancedObjectCowList() {
super();
}
@Override
public void initialize() throws IOException {
}
public EnhancedObjectCowList(IDatabase database, Class<T> type) throws IOException {
super(database);
this.type = type;
indices = new LongArrayList();
}
@Override
protected T loadItem(long uid) throws IOException {
return database.getObjectsIO().loadEnhancedObject(uid, type);
}
@Override
protected void writeItemToDisk(long uid, T item) throws IOException {
database.getObjectsIO().setEnhancedObject(uid, item);
}
}