Andrea Cavalli
10ca07d4c5
Added serialized classes update mechanism and removed the useless initialize method.
44 lines
1.0 KiB
Java
44 lines
1.0 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();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|