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

49 lines
1.1 KiB
Java
Raw Normal View History

2019-02-01 00:04:51 +01:00
package org.warp.cowdb.lists;
2019-02-05 17:56:28 +01:00
import it.unimi.dsi.fastutil.longs.LongArrayList;
2019-02-01 00:04:51 +01:00
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> {
2019-02-05 17:56:28 +01:00
@DBField(id = 0, type = DBDataType.REFERENCES_LIST)
private LongArrayList indices;
2019-02-01 00:04:51 +01:00
@DBField(id = 1, type = DBDataType.OBJECT)
private Class<T> type;
2019-02-05 17:56:28 +01:00
@Override
protected LongArrayList getIndices() {
return indices;
}
2019-02-01 00:04:51 +01:00
public EnhancedObjectCowList() {
super();
}
2019-02-05 17:56:28 +01:00
@Override
public void initialize() throws IOException {
}
2019-02-01 00:04:51 +01:00
public EnhancedObjectCowList(IDatabase database, Class<T> type) throws IOException {
super(database);
this.type = type;
2019-02-05 17:56:28 +01:00
indices = new LongArrayList();
2019-02-01 00:04:51 +01:00
}
@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);
}
}