strangedb/src/main/java/org/warp/cowdb/IObjectsIO.java

57 lines
1.6 KiB
Java

package org.warp.cowdb;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongList;
import org.warp.jcwdb.ann.DBDataType;
import java.io.IOException;
import java.lang.reflect.Method;
public interface IObjectsIO {
<T extends EnhancedObject> T loadEnhancedObject(long reference, Class<T> objectType) throws IOException;
<T> T loadObject(long reference) throws IOException;
LongArrayList loadReferencesList(long reference) throws IOException;
<T extends EnhancedObject> void setEnhancedObject(long reference, T value) throws IOException;
<T> void setObject(long reference, T value) throws IOException;
void setReferencesList(long reference, LongArrayList value) throws IOException;
long newNullObject() throws IOException;
default <T extends EnhancedObject> long newEnhancedObject(T value) throws IOException {
long reference = newNullObject();
if (value != null) {
setEnhancedObject(reference, value);
}
return reference;
}
default <T> long newObject(T value) throws IOException {
long reference = newNullObject();
if (value != null) {
setObject(reference, value);
}
return reference;
}
default long newReferencesList(LongArrayList value) throws IOException {
long reference = newNullObject();
if (value != null) {
setReferencesList(reference, value);
}
return reference;
}
void loadProperty(EnhancedObject enhancedObject, int propertyId, Method propertyGetter, DBDataType propertyType, long propertyUID) throws IOException;
void registerClass(Class<?> type, int id);
IDataInitializer getDataInitializer();
LongList loadPrimitiveData(long id) throws IOException;
}