2019-02-09 14:23:18 +01:00
|
|
|
package org.warp.jcwdb.tests;
|
|
|
|
|
2019-03-07 11:32:45 +01:00
|
|
|
import org.warp.jcwdb.EnhancedObject;
|
|
|
|
import org.warp.jcwdb.EnhancedObjectUpgrader;
|
|
|
|
import org.warp.jcwdb.database.IDatabaseTools;
|
|
|
|
import org.warp.jcwdb.annotations.DBClass;
|
|
|
|
import org.warp.jcwdb.annotations.DBDataType;
|
|
|
|
import org.warp.jcwdb.annotations.DBField;
|
|
|
|
import org.warp.jcwdb.annotations.DBPrimitiveField;
|
|
|
|
import org.warp.jcwdb.annotations.DBPrimitiveType;
|
2019-02-09 14:23:18 +01:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
@DBClass(version = 1)
|
|
|
|
public class V2Class extends EnhancedObject {
|
2019-03-06 17:25:56 +01:00
|
|
|
@DBPrimitiveField(id = 0, type = DBPrimitiveType.LONG)
|
2019-02-09 14:23:18 +01:00
|
|
|
public long field1;
|
|
|
|
|
2019-03-06 17:25:56 +01:00
|
|
|
@DBPrimitiveField(id = 1, type = DBPrimitiveType.INTEGER)
|
2019-02-09 14:23:18 +01:00
|
|
|
public int field2;
|
|
|
|
|
2019-03-06 17:25:56 +01:00
|
|
|
@DBField(id = 0, type = DBDataType.OBJECT)
|
2019-02-09 14:23:18 +01:00
|
|
|
public String field4;
|
|
|
|
|
2019-03-02 17:47:24 +01:00
|
|
|
public V2Class() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public V2Class(IDatabaseTools databaseTools) throws IOException {
|
|
|
|
super(databaseTools);
|
|
|
|
}
|
|
|
|
|
2019-02-09 14:23:18 +01:00
|
|
|
@Override
|
|
|
|
public void onUpgrade(int oldObjectVersion, EnhancedObjectUpgrader enhancedObjectUpgrader) throws IOException {
|
|
|
|
switch (oldObjectVersion) {
|
|
|
|
case 0: {
|
2019-03-06 17:25:56 +01:00
|
|
|
field1 = (long) enhancedObjectUpgrader.getPrimitiveInt(2);
|
|
|
|
field2 = enhancedObjectUpgrader.getPrimitiveInt(0);
|
2019-02-09 14:23:18 +01:00
|
|
|
field4 = (String) enhancedObjectUpgrader.getField(0, DBDataType.OBJECT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|