ifAbsent) throws IOException {
+ return database.loadRoot(rootClass, ifAbsent);
}
public void registerClass(Class> clazz, int id) {
if (id < 0) {
throw new IllegalArgumentException();
}
- database.registerClass(clazz, id);
+ dataLoader.registerClass(clazz, id);
}
public void close() throws IOException {
database.close();
}
+
+ public DataLoader getDataLoader() {
+ return dataLoader;
+ }
+
+ public DataInitializer getDataInitializer() {
+ return dataInitializer;
+ }
+
+ public void initializeDBObject(DBObject dbObject) throws IOException {
+ dataInitializer.initializeDBObject(dbObject);
+ }
}
diff --git a/src/main/java/org/warp/jcwdb/ann/RunnableWithIO.java b/src/main/java/org/warp/jcwdb/ann/RunnableWithIO.java
new file mode 100644
index 0000000..6f3215d
--- /dev/null
+++ b/src/main/java/org/warp/jcwdb/ann/RunnableWithIO.java
@@ -0,0 +1,19 @@
+package org.warp.jcwdb.ann;
+
+import java.io.IOException;
+
+@FunctionalInterface
+public interface RunnableWithIO {
+ /**
+ * When an object implementing interface Runnable
is used
+ * to create a thread, starting the thread causes the object's
+ * run
method to be called in that separately executing
+ * thread.
+ *
+ * The general contract of the method run
is that it may
+ * take any action whatsoever.
+ *
+ * @see java.lang.Thread#run()
+ */
+ public abstract void run() throws IOException;
+}
diff --git a/src/main/java/org/warp/jcwdb/ann/SupplierWithIO.java b/src/main/java/org/warp/jcwdb/ann/SupplierWithIO.java
new file mode 100644
index 0000000..2e8fa67
--- /dev/null
+++ b/src/main/java/org/warp/jcwdb/ann/SupplierWithIO.java
@@ -0,0 +1,8 @@
+package org.warp.jcwdb.ann;
+
+import java.io.IOException;
+
+@FunctionalInterface
+public interface SupplierWithIO {
+ public T getWithIO() throws IOException;
+}
\ No newline at end of file
diff --git a/src/test/java/org/warp/jcwdb/tests/DBDBObjectListTests.java b/src/test/java/org/warp/jcwdb/tests/DBDBObjectListTests.java
index 60eaaa3..f362f50 100644
--- a/src/test/java/org/warp/jcwdb/tests/DBDBObjectListTests.java
+++ b/src/test/java/org/warp/jcwdb/tests/DBDBObjectListTests.java
@@ -20,6 +20,7 @@ public class DBDBObjectListTests {
db.get().registerClass(TestUtils.class, 0);
db.get().registerClass(TestUtils.RootClass.class, 1);
db.get().registerClass(Class.class, 2);
+ System.out.println("Loading root");
root = db.get().loadRoot(RootWithList.class);
});
root.list = new DBDBObjectList<>(db.get(), TestUtils.RootClass.class);
@@ -37,7 +38,7 @@ public class DBDBObjectListTests {
}
@Test
- public void shouldMatchList() {
+ public void shouldMatchList() throws IOException {
checkEmptyList();
assertEquals(200, root.list.size());
for (int i = 0; i < 200; i++) {
@@ -45,7 +46,7 @@ public class DBDBObjectListTests {
}
}
- private void checkEmptyList() {
+ private void checkEmptyList() throws IOException {
DBObjectList list = new DBObjectList<>(db.get());
assertEquals(null, list.getLast());
assertEquals(0, list.size());
@@ -63,15 +64,20 @@ public class DBDBObjectListTests {
public static class RootWithList extends DBObject {
- public RootWithList(JCWDatabase database) {
+ @DBField(id = 0, type = DBDataType.DATABASE_OBJECT)
+ public DBDBObjectList list;
+
+ public RootWithList() {
+ super();
+ }
+
+ public RootWithList(JCWDatabase database) throws IOException {
super(database);
}
- public RootWithList(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
+ @Override
+ public void initialize() throws IOException {
+ list = new DBDBObjectList<>(database, TestUtils.RootClass.class);
}
-
- @DBField(id = 0, type = DBDataType.DATABASE_OBJECT)
- public DBDBObjectList list;
}
}
diff --git a/src/test/java/org/warp/jcwdb/tests/DBMultipleDBObjects.java b/src/test/java/org/warp/jcwdb/tests/DBMultipleDBObjects.java
index c0e0aa1..dc378fe 100644
--- a/src/test/java/org/warp/jcwdb/tests/DBMultipleDBObjects.java
+++ b/src/test/java/org/warp/jcwdb/tests/DBMultipleDBObjects.java
@@ -43,20 +43,20 @@ public class DBMultipleDBObjects {
public static class RootTwoClasses extends DBObject {
- public RootTwoClasses(JCWDatabase database) {
- super(database);
- }
-
- public RootTwoClasses(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
- }
-
@DBField(id = 0, type = DBDataType.DATABASE_OBJECT)
public TestUtils.RootClass class1;
@DBField(id = 1, type = DBDataType.DATABASE_OBJECT)
public TestUtils.RootClass class2;
+ public RootTwoClasses() {
+ super();
+ }
+
+ public RootTwoClasses(JCWDatabase database) throws IOException {
+ super(database);
+ }
+
@DBPropertyGetter(id = 0, type = DBDataType.DATABASE_OBJECT)
public TestUtils.RootClass getClass3() {
return getProperty();
@@ -76,5 +76,10 @@ public class DBMultipleDBObjects {
public void setClass4(TestUtils.RootClass value) {
setProperty(value);
}
+
+ @Override
+ public void initialize() throws IOException {
+
+ }
}
}
diff --git a/src/test/java/org/warp/jcwdb/tests/DBNestedDBObjects.java b/src/test/java/org/warp/jcwdb/tests/DBNestedDBObjects.java
index 73160df..5ad71a9 100644
--- a/src/test/java/org/warp/jcwdb/tests/DBNestedDBObjects.java
+++ b/src/test/java/org/warp/jcwdb/tests/DBNestedDBObjects.java
@@ -3,12 +3,9 @@ package org.warp.jcwdb.tests;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.warp.jcwdb.ann.*;
import org.warp.jcwdb.utils.NestedClass;
import org.warp.jcwdb.utils.TestUtils;
-import java.io.IOException;
-
import static org.junit.Assert.*;
public class DBNestedDBObjects {
diff --git a/src/test/java/org/warp/jcwdb/tests/DBRootCreation.java b/src/test/java/org/warp/jcwdb/tests/DBRootCreation.java
index ff962d0..4b2523b 100644
--- a/src/test/java/org/warp/jcwdb/tests/DBRootCreation.java
+++ b/src/test/java/org/warp/jcwdb/tests/DBRootCreation.java
@@ -10,7 +10,7 @@ import org.warp.jcwdb.utils.TestUtils;
import java.io.IOException;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
public class DBRootCreation {
private TestUtils.WrappedDb db;
@@ -21,7 +21,7 @@ public class DBRootCreation {
}
@Test
- public void shouldCreateRoot() {
+ public void shouldCreateRoot() throws IOException {
RootClass root = db.get().loadRoot(RootClass.class);
assertTrue(root.test());
}
@@ -33,16 +33,17 @@ public class DBRootCreation {
public static class RootClass extends DBObject {
- public RootClass(JCWDatabase database) {
+ public RootClass(JCWDatabase database) throws IOException {
super(database);
}
- public RootClass(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
- }
-
public boolean test() {
return true;
}
+
+ @Override
+ public void initialize() throws IOException {
+
+ }
}
}
diff --git a/src/test/java/org/warp/jcwdb/tests/NDBMultipleEnhancedObjects.java b/src/test/java/org/warp/jcwdb/tests/NDBMultipleEnhancedObjects.java
new file mode 100644
index 0000000..82abb62
--- /dev/null
+++ b/src/test/java/org/warp/jcwdb/tests/NDBMultipleEnhancedObjects.java
@@ -0,0 +1,90 @@
+package org.warp.jcwdb.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.warp.cowdb.EnhancedObject;
+import org.warp.cowdb.IDatabase;
+import org.warp.jcwdb.ann.DBDataType;
+import org.warp.jcwdb.ann.DBField;
+import org.warp.jcwdb.ann.DBPropertyGetter;
+import org.warp.jcwdb.ann.DBPropertySetter;
+import org.warp.jcwdb.utils.NTestUtils;
+
+import java.io.IOException;
+
+public class NDBMultipleEnhancedObjects {
+ private NTestUtils.WrappedDb db;
+ private RootTwoClasses root;
+
+ @Before
+ public void setUp() throws Exception {
+ db = NTestUtils.wrapDb().create((db) -> {
+ root = db.get().loadRoot(RootTwoClasses.class);
+ });
+ root.class1 = new NTestUtils.RootClass(db.get());
+ db.setRootClassValues(root.class1);
+ root.class2 = new NTestUtils.RootClass(db.get());
+ db.setRootClassValues(root.class2);
+ root.setClass3(new NTestUtils.RootClass(db.get()));
+ db.setRootClassValues(root.getClass3());
+ root.setClass4(new NTestUtils.RootClass(db.get()));
+ db.setRootClassValues(root.getClass4());
+ db.closeAndReopen();
+ }
+
+ @Test
+ public void shouldMatchMultipleEnhancedObjects() {
+ db.testRootClassValues(root.class1);
+ db.testRootClassValues(root.class2);
+ db.testRootClassValues(root.getClass3());
+ db.testRootClassValues(root.getClass4());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ db.delete();
+ }
+
+ public static class RootTwoClasses extends EnhancedObject {
+
+ @DBField(id = 0, type = DBDataType.DATABASE_OBJECT)
+ public NTestUtils.RootClass class1;
+
+ @DBField(id = 1, type = DBDataType.DATABASE_OBJECT)
+ public NTestUtils.RootClass class2;
+
+ public RootTwoClasses() {
+ super();
+ }
+
+ public RootTwoClasses(IDatabase database) throws IOException {
+ super(database);
+ }
+
+ @DBPropertyGetter(id = 0, type = DBDataType.DATABASE_OBJECT)
+ public NTestUtils.RootClass getClass3() {
+ return getProperty();
+ }
+
+ @DBPropertySetter(id = 0, type = DBDataType.DATABASE_OBJECT)
+ public void setClass3(NTestUtils.RootClass value) {
+ setProperty(value);
+ }
+
+ @DBPropertyGetter(id = 1, type = DBDataType.DATABASE_OBJECT)
+ public NTestUtils.RootClass getClass4() {
+ return getProperty();
+ }
+
+ @DBPropertySetter(id = 1, type = DBDataType.DATABASE_OBJECT)
+ public void setClass4(NTestUtils.RootClass value) {
+ setProperty(value);
+ }
+
+ @Override
+ public void initialize() throws IOException {
+
+ }
+ }
+}
diff --git a/src/test/java/org/warp/jcwdb/utils/ConsumerWithIO.java b/src/test/java/org/warp/jcwdb/utils/ConsumerWithIO.java
new file mode 100644
index 0000000..0b85738
--- /dev/null
+++ b/src/test/java/org/warp/jcwdb/utils/ConsumerWithIO.java
@@ -0,0 +1,32 @@
+package org.warp.jcwdb.utils;
+
+import java.io.IOException;
+import java.util.Objects;
+
+@FunctionalInterface
+public interface ConsumerWithIO {
+
+ /**
+ * Performs this operation on the given argument.
+ *
+ * @param t the input argument
+ */
+ void accept(T t) throws IOException;
+
+ /**
+ * Returns a composed {@code Consumer} that performs, in sequence, this
+ * operation followed by the {@code after} operation. If performing either
+ * operation throws an exception, it is relayed to the caller of the
+ * composed operation. If performing this operation throws an exception,
+ * the {@code after} operation will not be performed.
+ *
+ * @param after the operation to perform after this operation
+ * @return a composed {@code Consumer} that performs in sequence this
+ * operation followed by the {@code after} operation
+ * @throws NullPointerException if {@code after} is null
+ */
+ default ConsumerWithIO andThen(ConsumerWithIO super T> after) {
+ Objects.requireNonNull(after);
+ return (T t) -> { accept(t); after.accept(t); };
+ }
+}
diff --git a/src/test/java/org/warp/jcwdb/utils/NSimplestClass.java b/src/test/java/org/warp/jcwdb/utils/NSimplestClass.java
new file mode 100644
index 0000000..55f76d6
--- /dev/null
+++ b/src/test/java/org/warp/jcwdb/utils/NSimplestClass.java
@@ -0,0 +1,29 @@
+package org.warp.jcwdb.utils;
+
+import org.warp.cowdb.Database;
+import org.warp.cowdb.EnhancedObject;
+import org.warp.jcwdb.ann.DBDataType;
+import org.warp.jcwdb.ann.DBField;
+import org.warp.jcwdb.ann.DBObject;
+import org.warp.jcwdb.ann.JCWDatabase;
+
+import java.io.IOException;
+
+public class NSimplestClass extends EnhancedObject {
+
+ @DBField(id = 0, type = DBDataType.BOOLEAN)
+ public boolean field1;
+
+ public NSimplestClass() {
+
+ }
+
+ public NSimplestClass(Database database) throws IOException {
+ super(database);
+ }
+
+ @Override
+ public void initialize() throws IOException {
+ field1 = true;
+ }
+}
diff --git a/src/test/java/org/warp/jcwdb/utils/NTestUtils.java b/src/test/java/org/warp/jcwdb/utils/NTestUtils.java
new file mode 100644
index 0000000..ffbae03
--- /dev/null
+++ b/src/test/java/org/warp/jcwdb/utils/NTestUtils.java
@@ -0,0 +1,383 @@
+package org.warp.jcwdb.utils;
+
+import it.unimi.dsi.fastutil.longs.LongArrayList;
+import org.warp.cowdb.Database;
+import org.warp.cowdb.EnhancedObject;
+import org.warp.cowdb.IDatabase;
+import org.warp.jcwdb.ann.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Comparator;
+
+import static org.junit.Assert.*;
+
+public class NTestUtils {
+ public static WrappedDb wrapDb() {
+ return new WrappedDb();
+ }
+
+ public static class WrappedDb {
+
+ private Database db;
+ private Path tempDir;
+ private RunnableWithIO r;
+
+ private WrappedDb() {
+
+ }
+
+ public WrappedDb create() throws IOException {
+ tempDir = Files.createTempDirectory("tests-");
+ db = openDatabase();
+ if (r != null) {
+ r.run();
+ }
+ return this;
+ }
+
+ public WrappedDb create(ConsumerWithIO r) throws IOException {
+ this.r = () -> r.accept(WrappedDb.this);
+ this.create();
+ return this;
+ }
+
+ private Database openDatabase() throws IOException {
+ return new Database(tempDir.resolve(Paths.get("data.db")), tempDir.resolve(Paths.get("blocks.dat")), tempDir.resolve(Paths.get("references.dat")));
+ }
+
+ public void delete() throws IOException {
+ db.close();
+ deleteDir(tempDir);
+ }
+
+ public Database get() {
+ return db;
+ }
+
+ private void deleteDir(Path p) throws IOException {
+ Files.walk(p)
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
+ }
+
+ public void closeAndReopen() throws IOException {
+ db.close();
+ db = openDatabase();
+ r.run();
+ }
+
+ public void setRootClassValues(RootClass root) throws IOException {
+ setRootClassFields(root);
+ setRootClassProperties(root);
+ }
+
+ public void setRootClassFields(RootClass root) throws IOException {
+ root.field1 = true;
+ root.field2 = 2;
+ root.field3 = 3;
+ root.field4 = 4;
+ root.field5 = 5;
+ root.field6 = 6;
+ root.field7 = "Test";
+ root.field8 = new LongArrayList();
+ root.field8.add(0);
+ root.field8.add(1);
+ root.field8.add(2);
+ root.field8.add(Long.MAX_VALUE/2);
+ root.field8.add(Long.MIN_VALUE/2);
+ root.field8.add(Long.MAX_VALUE);
+ root.field8.add(Long.MIN_VALUE);
+ root.field9 = new NSimplestClass(db);
+ root.field9.field1 = true;
+
+ }
+
+ public void setRootClassProperties(RootClass root) throws IOException {
+ root.set1(true);
+ root.set2((byte)2);
+ root.set3((short)3);
+ root.set4((char)4);
+ root.set5(5);
+ root.set6(6);
+ root.set7("Test");
+ LongArrayList lArrayList = new LongArrayList();
+ lArrayList.add(0);
+ lArrayList.add(1);
+ lArrayList.add(2);
+ lArrayList.add(Long.MAX_VALUE/2);
+ lArrayList.add(Long.MIN_VALUE/2);
+ lArrayList.add(Long.MAX_VALUE);
+ lArrayList.add(Long.MIN_VALUE);
+ root.set8(lArrayList);
+ NSimplestClass simplestClass9 = new NSimplestClass(db);
+ simplestClass9.field1 = true;
+ root.set9(simplestClass9);
+ }
+
+ public void testRootClassValues(RootClass root) {
+ testRootClassFields(root);
+ testRootClassProperties(root);
+ }
+
+ public void testRootClassFields(RootClass root) {
+ shouldGetFieldBoolean(root);
+ shouldGetFieldByte(root);
+ shouldGetFieldShort(root);
+ shouldGetFieldCharacter(root);
+ shouldGetFieldInteger(root);
+ shouldGetFieldLong(root);
+ shouldGetFieldObject(root);
+ shouldGetFieldUID(root);
+ shouldGetFieldDBObject(root);
+ }
+
+ public void testRootClassProperties(RootClass root) {
+ shouldGetPropertyBoolean(root);
+ shouldGetPropertyByte(root);
+ shouldGetPropertyShort(root);
+ shouldGetPropertyCharacter(root);
+ shouldGetPropertyInteger(root);
+ shouldGetPropertyLong(root);
+ shouldGetPropertyObject(root);
+ shouldGetPropertyUID(root);
+ shouldGetPropertyDBObject(root);
+ }
+
+
+ private void shouldGetFieldBoolean(RootClass root) {
+ assertTrue(root.field1);
+ }
+
+ private void shouldGetPropertyBoolean(RootClass root) {
+ assertTrue(root.get1());
+ }
+
+ private void shouldGetFieldByte(RootClass root) {
+ assertEquals(2, root.field2);
+ }
+
+ private void shouldGetPropertyByte(RootClass root) {
+ assertEquals(2, root.get2());
+ }
+
+ private void shouldGetFieldShort(RootClass root) {
+ assertEquals(3, root.field3);
+ }
+
+ private void shouldGetPropertyShort(RootClass root) {
+ assertEquals(3, root.get3());
+ }
+
+ private void shouldGetFieldCharacter(RootClass root) {
+ assertEquals(4, root.field4);
+ }
+
+ private void shouldGetPropertyCharacter(RootClass root) {
+ assertEquals(4, root.get4());
+ }
+
+ private void shouldGetFieldInteger(RootClass root) {
+ assertEquals(5, root.field5);
+ }
+
+ private void shouldGetPropertyInteger(RootClass root) {
+ assertEquals(5, root.get5());
+ }
+
+ private void shouldGetFieldLong(RootClass root) {
+ assertEquals(6, root.field6);
+ }
+
+ private void shouldGetPropertyLong(RootClass root) {
+ assertEquals(6, root.get6());
+ }
+
+ private void shouldGetFieldObject(RootClass root) {
+ shouldGetObject(root.field7);
+ }
+
+ private void shouldGetPropertyObject(RootClass root) {
+ shouldGetObject(root.get7());
+ }
+
+ private void shouldGetFieldDBObject(RootClass root) {
+ assertTrue(root.field9.field1);
+ }
+
+ private void shouldGetPropertyDBObject(RootClass root) {
+ assertTrue(root.get9().field1);
+ }
+
+ private void shouldGetObject(String val) {
+ assertNotNull(val);
+ assertEquals("Test", val);
+ }
+
+ private void shouldGetDBObject(SimplestClass val) {
+ assertNotNull(val);
+ assertTrue(val.field1);
+ }
+
+ private void shouldGetFieldUID(RootClass root) {
+ shouldGetUID(root.field8);
+ }
+
+ private void shouldGetPropertyUID(RootClass root) {
+ shouldGetUID(root.get8());
+ }
+
+ private void shouldGetUID(LongArrayList val) {
+ assertNotNull(val);
+ assertEquals(7, val.size());
+ assertEquals(0, val.getLong(0));
+ assertEquals(val.getLong(5), Long.MAX_VALUE);
+ assertEquals(val.getLong(6), Long.MIN_VALUE);
+ }
+
+ public void onLoad(RunnableWithIO r) {
+ this.r = r;
+ }
+ }
+
+ public static class RootClass extends EnhancedObject {
+
+ @DBField(id = 0, type = DBDataType.BOOLEAN)
+ public boolean field1;
+
+ @DBField(id = 1, type = DBDataType.BYTE)
+ public byte field2;
+
+ @DBField(id = 2, type = DBDataType.SHORT)
+ public short field3;
+
+ @DBField(id = 3, type = DBDataType.CHAR)
+ public char field4;
+
+ @DBField(id = 4, type = DBDataType.INTEGER)
+ public int field5;
+
+ @DBField(id = 5, type = DBDataType.LONG)
+ public long field6;
+
+ @DBField(id = 6, type = DBDataType.OBJECT)
+ public String field7;
+
+ @DBField(id = 7, type = DBDataType.REFERENCES_LIST)
+ public LongArrayList field8;
+
+ @DBField(id = 8, type = DBDataType.DATABASE_OBJECT)
+ public NSimplestClass field9;
+
+ public RootClass() {
+
+ }
+
+ public RootClass(IDatabase database) throws IOException {
+ super(database);
+ }
+
+ @DBPropertyGetter(id = 0, type = DBDataType.BOOLEAN)
+ public boolean get1() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 1, type = DBDataType.BYTE)
+ public byte get2() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 2, type = DBDataType.SHORT)
+ public short get3() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 3, type = DBDataType.CHAR)
+ public char get4() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 4, type = DBDataType.INTEGER)
+ public int get5() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 5, type = DBDataType.LONG)
+ public long get6() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 6, type = DBDataType.OBJECT)
+ public String get7() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 7, type = DBDataType.REFERENCES_LIST)
+ public LongArrayList get8() {
+ return getProperty();
+ }
+
+ @DBPropertyGetter(id = 8, type = DBDataType.DATABASE_OBJECT)
+ public NSimplestClass get9() {
+ return getProperty();
+ }
+
+ @DBPropertySetter(id = 0, type = DBDataType.BOOLEAN)
+ public void set1(boolean val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 1, type = DBDataType.BYTE)
+ public void set2(byte val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 2, type = DBDataType.SHORT)
+ public void set3(short val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 3, type = DBDataType.CHAR)
+ public void set4(char val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 4, type = DBDataType.INTEGER)
+ public void set5(int val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 5, type = DBDataType.LONG)
+ public void set6(long val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 6, type = DBDataType.OBJECT)
+ public void set7(String val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 7, type = DBDataType.REFERENCES_LIST)
+ public void set8(LongArrayList val) {
+ setProperty(val);
+ }
+
+ @DBPropertySetter(id = 8, type = DBDataType.DATABASE_OBJECT)
+ public void set9(NSimplestClass val) {
+ setProperty(val);
+ }
+
+ public boolean test() {
+ return true;
+ }
+
+ @Override
+ public void initialize() throws IOException {
+
+ }
+ }
+}
diff --git a/src/test/java/org/warp/jcwdb/utils/NestedClass.java b/src/test/java/org/warp/jcwdb/utils/NestedClass.java
index 7a53bb3..042cbd4 100644
--- a/src/test/java/org/warp/jcwdb/utils/NestedClass.java
+++ b/src/test/java/org/warp/jcwdb/utils/NestedClass.java
@@ -12,6 +12,14 @@ public class NestedClass extends DBObject {
@DBField(id = 1, type = DBDataType.DATABASE_OBJECT)
public NestedClass child;
+ public NestedClass() {
+
+ }
+
+ public NestedClass(JCWDatabase database) throws IOException {
+ super(database);
+ }
+
@DBPropertySetter(id = 0, type = DBDataType.DATABASE_OBJECT)
public void setValue(NestedClass value) {
setProperty(value);
@@ -22,11 +30,8 @@ public class NestedClass extends DBObject {
return getProperty();
}
- public NestedClass(JCWDatabase database) {
- super(database);
- }
+ @Override
+ public void initialize() throws IOException {
- public NestedClass(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
}
}
diff --git a/src/test/java/org/warp/jcwdb/utils/SimplestClass.java b/src/test/java/org/warp/jcwdb/utils/SimplestClass.java
index e73e55d..2791395 100644
--- a/src/test/java/org/warp/jcwdb/utils/SimplestClass.java
+++ b/src/test/java/org/warp/jcwdb/utils/SimplestClass.java
@@ -9,12 +9,16 @@ public class SimplestClass extends DBObject {
@DBField(id = 0, type = DBDataType.BOOLEAN)
public boolean field1;
- public SimplestClass(JCWDatabase database) {
- super(database);
- field1 = true;
+ public SimplestClass() {
+
}
- public SimplestClass(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
+ public SimplestClass(JCWDatabase database) throws IOException {
+ super(database);
+ }
+
+ @Override
+ public void initialize() throws IOException {
+ field1 = true;
}
}
diff --git a/src/test/java/org/warp/jcwdb/utils/TestUtils.java b/src/test/java/org/warp/jcwdb/utils/TestUtils.java
index 5f8c632..ed622e0 100644
--- a/src/test/java/org/warp/jcwdb/utils/TestUtils.java
+++ b/src/test/java/org/warp/jcwdb/utils/TestUtils.java
@@ -12,7 +12,6 @@ import java.util.Comparator;
import java.util.function.Consumer;
import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
public class TestUtils {
public static WrappedDb wrapDb() {
@@ -23,7 +22,7 @@ public class TestUtils {
private JCWDatabase db;
private Path tempDir;
- private Runnable r;
+ private RunnableWithIO r;
private WrappedDb() {
@@ -38,7 +37,7 @@ public class TestUtils {
return this;
}
- public WrappedDb create(Consumer r) throws IOException {
+ public WrappedDb create(ConsumerWithIO r) throws IOException {
this.r = () -> r.accept(WrappedDb.this);
this.create();
return this;
@@ -70,12 +69,12 @@ public class TestUtils {
r.run();
}
- public void setRootClassValues(RootClass root) {
+ public void setRootClassValues(RootClass root) throws IOException {
setRootClassFields(root);
setRootClassProperties(root);
}
- public void setRootClassFields(RootClass root) {
+ public void setRootClassFields(RootClass root) throws IOException {
root.field1 = true;
root.field2 = 2;
root.field3 = 3;
@@ -96,7 +95,7 @@ public class TestUtils {
}
- public void setRootClassProperties(RootClass root) {
+ public void setRootClassProperties(RootClass root) throws IOException {
root.set1(true);
root.set2((byte)2);
root.set3((short)3);
@@ -238,7 +237,7 @@ public class TestUtils {
assertEquals(val.getLong(6), Long.MIN_VALUE);
}
- public void onLoad(Runnable r) {
+ public void onLoad(RunnableWithIO r) {
this.r = r;
}
}
@@ -272,6 +271,14 @@ public class TestUtils {
@DBField(id = 8, type = DBDataType.DATABASE_OBJECT)
public SimplestClass field9;
+ public RootClass() {
+
+ }
+
+ public RootClass(JCWDatabase database) throws IOException {
+ super(database);
+ }
+
@DBPropertyGetter(id = 0, type = DBDataType.BOOLEAN)
public boolean get1() {
return getProperty();
@@ -362,16 +369,13 @@ public class TestUtils {
setProperty(val);
}
- public RootClass(JCWDatabase database) {
- super(database);
- }
-
- public RootClass(JCWDatabase database, DBObjectIndicesManager.DBObjectInfo objectInfo) throws IOException {
- super(database, objectInfo);
- }
-
public boolean test() {
return true;
}
+
+ @Override
+ public void initialize() throws IOException {
+
+ }
}
}