32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package org.warp.cowdb.database;
|
|
|
|
import org.warp.cowdb.EnhancedObjectUpgrader;
|
|
import org.warp.jcwdb.ann.DBDataType;
|
|
|
|
import java.io.IOException;
|
|
import java.util.function.Supplier;
|
|
|
|
public class DatabaseEnhancedObjectUpgrader implements EnhancedObjectUpgrader {
|
|
private final DatabaseObjectsIO objectsIO;
|
|
private final long[] fieldRefs;
|
|
private final long[] methodRefs;
|
|
|
|
public DatabaseEnhancedObjectUpgrader(DatabaseObjectsIO objectsIO, long[] fieldRefs, long[] methodRefs) {
|
|
this.objectsIO = objectsIO;
|
|
this.fieldRefs = fieldRefs;
|
|
this.methodRefs = methodRefs;
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public Object getField(int id, DBDataType type, Supplier<Class<?>> enhancedClassType) throws IOException {
|
|
return objectsIO.loadData(type, fieldRefs[id], enhancedClassType);
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public Object getMethod(int id, DBDataType type, Supplier<Class<?>> enhancedClassType) throws IOException {
|
|
return objectsIO.loadData(type, methodRefs[id], enhancedClassType);
|
|
}
|
|
}
|