strangedb/src/main/java/it/cavallium/strangedb/java/database/IObjectsIO.java

62 lines
1.9 KiB
Java

package it.cavallium.strangedb.java.database;
import it.cavallium.strangedb.java.objects.EnhancedObject;
import it.cavallium.strangedb.java.annotations.DbDataType;
import it.cavallium.strangedb.java.objects.EnhancedObjectIndices;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongList;
import java.io.IOException;
import java.lang.reflect.Method;
public interface IObjectsIO {
@SuppressWarnings("unchecked")
<T extends EnhancedObject> T loadEnhancedObject(long reference) throws IOException;
EnhancedObjectIndices loadEnhancedObjectUids(long reference) 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, DbDataType propertyType, long propertyUID) throws IOException;
void registerClass(Class<?> type, int id);
IDataInitializer getDataInitializer();
LongList loadPrimitiveData(long id) throws IOException;
}