Skip to content

Commit b2c3d39

Browse files
Update TestEntity classes to match latest generated code.
1 parent e9de468 commit b2c3d39

File tree

4 files changed

+50
-51
lines changed

4 files changed

+50
-51
lines changed

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntityCursor.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* Cursor for DB entity "TestEntity".
2727
*/
2828
public final class TestEntityCursor extends Cursor<TestEntity> {
29+
30+
// For testing
2931
public static boolean INT_NULL_HACK;
3032

3133
@Internal
@@ -35,10 +37,7 @@ public Cursor<TestEntity> createCursor(Transaction tx, long cursorHandle, BoxSto
3537
}
3638
}
3739

38-
private static final TestEntity_ PROPERTIES = new TestEntity_();
39-
40-
private static final TestEntity_.TestEntityIdGetter ID_GETTER = PROPERTIES.__ID_GETTER;
41-
40+
private static final TestEntity_.TestEntityIdGetter ID_GETTER = TestEntity_.__ID_GETTER;
4241

4342
// Property IDs get verified in Cursor base class
4443
private final static int __ID_simpleBoolean = TestEntity_.simpleBoolean.id;
@@ -52,7 +51,7 @@ public Cursor<TestEntity> createCursor(Transaction tx, long cursorHandle, BoxSto
5251
private final static int __ID_simpleByteArray = TestEntity_.simpleByteArray.id;
5352

5453
public TestEntityCursor(Transaction tx, long cursor, BoxStore boxStore) {
55-
super(tx, cursor, PROPERTIES, boxStore);
54+
super(tx, cursor, TestEntity_.__INSTANCE, boxStore);
5655
}
5756

5857
@Override
@@ -68,20 +67,14 @@ public final long getId(TestEntity entity) {
6867
@Override
6968
public final long put(TestEntity entity) {
7069
long __assignedId = collect313311(cursor, entity.getId(), PUT_FLAG_FIRST | PUT_FLAG_COMPLETE,
71-
9, entity.getSimpleString(), 0, null, 0, null,
72-
10, entity.getSimpleByteArray(),
73-
0, 0, 6, entity.getSimpleLong(), INT_NULL_HACK ? 0 : 5, entity.getSimpleInt(),
74-
4, entity.getSimpleShort(), 3, entity.getSimpleByte(),
75-
2, entity.getSimpleBoolean() ? 1 : 0,
76-
7, entity.getSimpleFloat(), 8, entity.getSimpleDouble()
77-
);
70+
__ID_simpleString, entity.getSimpleString(), 0, null,
71+
0, null, __ID_simpleByteArray, entity.getSimpleByteArray(),
72+
0, 0, __ID_simpleLong, entity.getSimpleLong(),
73+
INT_NULL_HACK ? 0 : __ID_simpleInt, entity.getSimpleInt(), __ID_simpleShort, entity.getSimpleShort(),
74+
__ID_simpleByte, entity.getSimpleByte(), __ID_simpleBoolean, entity.getSimpleBoolean() ? 1 : 0,
75+
__ID_simpleFloat, entity.getSimpleFloat(), __ID_simpleDouble, entity.getSimpleDouble());
7876
entity.setId(__assignedId);
7977
return __assignedId;
8078
}
8179

82-
// TODO do we need this? @Override
83-
protected final boolean isEntityUpdateable() {
84-
return true;
85-
}
86-
8780
}

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntityMinimalCursor.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
import io.objectbox.annotation.apihint.Internal;
2020
import io.objectbox.internal.CursorFactory;
21-
import io.objectbox.internal.IdGetter;
2221

2322
public class TestEntityMinimalCursor extends Cursor<TestEntityMinimal> {
24-
private static final TestEntityMinimal_ PROPERTIES = new TestEntityMinimal_();
2523

2624
@Internal
2725
static final class Factory implements CursorFactory<TestEntityMinimal> {
@@ -30,23 +28,33 @@ public Cursor<TestEntityMinimal> createCursor(Transaction tx, long cursorHandle,
3028
}
3129
}
3230

31+
private final static int __ID_test = TestEntityMinimal_.text.id;
32+
3333
public TestEntityMinimalCursor(Transaction tx, long cursor, BoxStore boxStore) {
34-
super(tx, cursor, PROPERTIES, boxStore);
34+
super(tx, cursor, TestEntityMinimal_.__INSTANCE, boxStore);
3535
}
3636

3737
@Override
3838
protected long getId(TestEntityMinimal entity) {
3939
return entity.getId();
4040
}
4141

42+
/**
43+
* Puts an object into its box.
44+
*
45+
* @return The ID of the object within its box.
46+
*/
47+
@Override
4248
public long put(TestEntityMinimal entity) {
43-
long key = entity.getId();
44-
key = collect313311(cursor, key, PUT_FLAG_FIRST | PUT_FLAG_COMPLETE,
45-
2, entity.getText(), 0, null, 0, null,
46-
0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
47-
);
48-
entity.setId(key);
49-
return key;
49+
long __assignedId = collect313311(cursor, entity.getId(), PUT_FLAG_FIRST | PUT_FLAG_COMPLETE,
50+
__ID_test, entity.getText(), 0, null,
51+
0, null, 0, null,
52+
0, 0, 0, 0,
53+
0, 0, 0, 0,
54+
0, 0, 0, 0,
55+
0, 0, 0, 0);
56+
entity.setId(__assignedId);
57+
return __assignedId;
5058
}
5159

5260
}

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntityMinimal_.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,16 @@ public long getId(TestEntityMinimal object) {
4949

5050
public final static TestEntityMinimal_ __INSTANCE = new TestEntityMinimal_();
5151

52-
private static int ID;
52+
public final static Property<TestEntityMinimal> id = new Property<>(__INSTANCE, 0, 1, long.class, "id", true, "id");
53+
public final static Property<TestEntityMinimal> text = new Property<>(__INSTANCE, 1, 2, String.class, "text", false, "text");
5354

54-
public final static Property id = new Property(__INSTANCE, ID++, ID, long.class, "id", true, "id");
55-
public final static Property text = new Property(__INSTANCE, ID++, ID, String.class, "text", false, "text");
56-
57-
public final static Property[] __ALL_PROPERTIES = {
55+
@SuppressWarnings("unchecked")
56+
public final static Property<TestEntityMinimal>[] __ALL_PROPERTIES = new Property[]{
5857
id,
5958
text,
6059
};
6160

62-
public final static Property __ID_PROPERTY = id;
61+
public final static Property<TestEntityMinimal> __ID_PROPERTY = id;
6362

6463
@Override
6564
public String getEntityName() {
@@ -82,12 +81,12 @@ public String getDbName() {
8281
}
8382

8483
@Override
85-
public Property[] getAllProperties() {
84+
public Property<TestEntityMinimal>[] getAllProperties() {
8685
return __ALL_PROPERTIES;
8786
}
8887

8988
@Override
90-
public Property getIdProperty() {
89+
public Property<TestEntityMinimal> getIdProperty() {
9190
return __ID_PROPERTY;
9291
}
9392

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntity_.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,18 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
4444

4545
public final static TestEntity_ __INSTANCE = new TestEntity_();
4646

47-
private static int ID;
48-
49-
public final static Property<TestEntity> id = new Property(__INSTANCE, ID++, ID, long.class, "id", true, "id");
50-
public final static Property<TestEntity> simpleBoolean = new Property(__INSTANCE, ID++, ID, boolean.class, "simpleBoolean", false, "simpleBoolean");
51-
public final static Property<TestEntity> simpleByte = new Property(__INSTANCE, ID++, ID, byte.class, "simpleByte", false, "simpleByte");
52-
public final static Property<TestEntity> simpleShort = new Property(__INSTANCE, ID++, ID, short.class, "simpleShort", false, "simpleShort");
53-
public final static Property<TestEntity> simpleInt = new Property(__INSTANCE, ID++, ID, int.class, "simpleInt", false, "simpleInt");
54-
public final static Property<TestEntity> simpleLong = new Property(__INSTANCE, ID++, ID, long.class, "simpleLong", false, "simpleLong");
55-
public final static Property<TestEntity> simpleFloat = new Property(__INSTANCE, ID++, ID, float.class, "simpleFloat", false, "simpleFloat");
56-
public final static Property<TestEntity> simpleDouble = new Property(__INSTANCE, ID++, ID, double.class, "simpleDouble", false, "simpleDouble");
57-
public final static Property<TestEntity> simpleString = new Property(__INSTANCE, ID++, ID, String.class, "simpleString", false, "simpleString");
58-
public final static Property<TestEntity> simpleByteArray = new Property(__INSTANCE, ID++, ID, byte[].class, "simpleByteArray", false, "simpleByteArray");
59-
47+
public final static Property<TestEntity> id = new Property<>(__INSTANCE, 0, 1, long.class, "id", true, "id");
48+
public final static Property<TestEntity> simpleBoolean = new Property<>(__INSTANCE, 1, 2, boolean.class, "simpleBoolean", false, "simpleBoolean");
49+
public final static Property<TestEntity> simpleByte = new Property<>(__INSTANCE, 2, 3, byte.class, "simpleByte", false, "simpleByte");
50+
public final static Property<TestEntity> simpleShort = new Property<>(__INSTANCE, 3, 4, short.class, "simpleShort", false, "simpleShort");
51+
public final static Property<TestEntity> simpleInt = new Property<>(__INSTANCE, 4, 5, int.class, "simpleInt", false, "simpleInt");
52+
public final static Property<TestEntity> simpleLong = new Property<>(__INSTANCE, 5, 6, long.class, "simpleLong", false, "simpleLong");
53+
public final static Property<TestEntity> simpleFloat = new Property<>(__INSTANCE, 6, 7, float.class, "simpleFloat", false, "simpleFloat");
54+
public final static Property<TestEntity> simpleDouble = new Property<>(__INSTANCE, 7, 8, double.class, "simpleDouble", false, "simpleDouble");
55+
public final static Property<TestEntity> simpleString = new Property<>(__INSTANCE, 8, 9, String.class, "simpleString", false, "simpleString");
56+
public final static Property<TestEntity> simpleByteArray = new Property<>(__INSTANCE, 9, 10, byte[].class, "simpleByteArray", false, "simpleByteArray");
57+
58+
@SuppressWarnings("unchecked")
6059
public final static Property<TestEntity>[] __ALL_PROPERTIES = new Property[]{
6160
id,
6261
simpleInt,
@@ -68,7 +67,7 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
6867
simpleByteArray
6968
};
7069

71-
public final static Property __ID_PROPERTY = id;
70+
public final static Property<TestEntity> __ID_PROPERTY = id;
7271

7372
@Override
7473
public String getEntityName() {
@@ -91,12 +90,12 @@ public String getDbName() {
9190
}
9291

9392
@Override
94-
public Property[] getAllProperties() {
93+
public Property<TestEntity>[] getAllProperties() {
9594
return __ALL_PROPERTIES;
9695
}
9796

9897
@Override
99-
public Property getIdProperty() {
98+
public Property<TestEntity> getIdProperty() {
10099
return __ID_PROPERTY;
101100
}
102101

0 commit comments

Comments
 (0)