Skip to content

Commit 408d78b

Browse files
Update TestEntity_ and TestEntityCursor to latest format.
1 parent e9844fc commit 408d78b

File tree

3 files changed

+70
-34
lines changed

3 files changed

+70
-34
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package io.objectbox;
1818

19+
/** In "real" entity would be annotated with @Entity. */
1920
public class TestEntity {
2021

22+
/** In "real" entity would be annotated with @Id. */
2123
private long id;
2224
private boolean simpleBoolean;
2325
private byte simpleByte;

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
package io.objectbox;
1818

19-
2019
import io.objectbox.annotation.apihint.Internal;
2120
import io.objectbox.internal.CursorFactory;
2221

23-
// THIS CODE IS based on GENERATED code BY ObjectBox
22+
// NOTE: Copied from a plugin project (& removed some unused Properties).
23+
// THIS CODE IS GENERATED BY ObjectBox, DO NOT EDIT.
2424

2525
/**
26-
* Cursor for DB entity "TestEntity".
26+
* ObjectBox generated Cursor implementation for "TestEntity".
27+
* Note that this is a low-level class: usually you should stick to the Box class.
2728
*/
2829
public final class TestEntityCursor extends Cursor<TestEntity> {
2930

@@ -32,14 +33,15 @@ public final class TestEntityCursor extends Cursor<TestEntity> {
3233

3334
@Internal
3435
static final class Factory implements CursorFactory<TestEntity> {
35-
public Cursor<TestEntity> createCursor(Transaction tx, long cursorHandle, BoxStore boxStoreForEntities) {
36+
@Override
37+
public Cursor<TestEntity> createCursor(io.objectbox.Transaction tx, long cursorHandle, BoxStore boxStoreForEntities) {
3638
return new TestEntityCursor(tx, cursorHandle, boxStoreForEntities);
3739
}
3840
}
3941

4042
private static final TestEntity_.TestEntityIdGetter ID_GETTER = TestEntity_.__ID_GETTER;
4143

42-
// Property IDs get verified in Cursor base class
44+
4345
private final static int __ID_simpleBoolean = TestEntity_.simpleBoolean.id;
4446
private final static int __ID_simpleByte = TestEntity_.simpleByte.id;
4547
private final static int __ID_simpleShort = TestEntity_.simpleShort.id;
@@ -50,7 +52,7 @@ public Cursor<TestEntity> createCursor(Transaction tx, long cursorHandle, BoxSto
5052
private final static int __ID_simpleString = TestEntity_.simpleString.id;
5153
private final static int __ID_simpleByteArray = TestEntity_.simpleByteArray.id;
5254

53-
public TestEntityCursor(Transaction tx, long cursor, BoxStore boxStore) {
55+
public TestEntityCursor(io.objectbox.Transaction tx, long cursor, BoxStore boxStore) {
5456
super(tx, cursor, TestEntity_.__INSTANCE, boxStore);
5557
}
5658

@@ -66,14 +68,21 @@ public final long getId(TestEntity entity) {
6668
*/
6769
@Override
6870
public final long put(TestEntity entity) {
71+
String simpleString = entity.getSimpleString();
72+
int __id8 = simpleString != null ? __ID_simpleString : 0;
73+
byte[] simpleByteArray = entity.getSimpleByteArray();
74+
int __id9 = simpleByteArray != null ? __ID_simpleByteArray : 0;
75+
6976
long __assignedId = collect313311(cursor, entity.getId(), PUT_FLAG_FIRST | PUT_FLAG_COMPLETE,
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,
77+
__id8, simpleString, 0, null,
78+
0, null, __id9, simpleByteArray,
79+
__ID_simpleLong, entity.getSimpleLong(), INT_NULL_HACK ? 0 : __ID_simpleInt, entity.getSimpleInt(),
80+
__ID_simpleShort, entity.getSimpleShort(), __ID_simpleByte, entity.getSimpleByte(),
81+
__ID_simpleBoolean, entity.getSimpleBoolean() ? 1 : 0, 0, 0,
7582
__ID_simpleFloat, entity.getSimpleFloat(), __ID_simpleDouble, entity.getSimpleDouble());
83+
7684
entity.setId(__assignedId);
85+
7786
return __assignedId;
7887
}
7988

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

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
package io.objectbox;
1919

20-
// Copied from generated tests (& removed some unused Properties)
21-
2220
import io.objectbox.TestEntityCursor.Factory;
2321
import io.objectbox.annotation.apihint.Internal;
2422
import io.objectbox.internal.CursorFactory;
2523
import io.objectbox.internal.IdGetter;
2624

25+
// NOTE: Copied from a plugin project (& removed some unused Properties).
26+
// THIS CODE IS GENERATED BY ObjectBox, DO NOT EDIT.
27+
2728
/**
2829
* Properties for entity "TestEntity". Can be used for QueryBuilder and for referencing DB names.
2930
*/
@@ -33,6 +34,8 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
3334

3435
public static final String __ENTITY_NAME = "TestEntity";
3536

37+
public static final int __ENTITY_ID = 1;
38+
3639
public static final Class<TestEntity> __ENTITY_CLASS = TestEntity.class;
3740

3841
public static final String __DB_NAME = "TestEntity";
@@ -44,44 +47,65 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
4447

4548
public final static TestEntity_ __INSTANCE = new TestEntity_();
4649

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");
50+
public final static io.objectbox.Property<TestEntity> id =
51+
new io.objectbox.Property<>(__INSTANCE, 0, 1, long.class, "id", true, "id");
52+
53+
public final static io.objectbox.Property<TestEntity> simpleBoolean =
54+
new io.objectbox.Property<>(__INSTANCE, 1, 2, boolean.class, "simpleBoolean");
55+
56+
public final static io.objectbox.Property<TestEntity> simpleByte =
57+
new io.objectbox.Property<>(__INSTANCE, 2, 3, byte.class, "simpleByte");
58+
59+
public final static io.objectbox.Property<TestEntity> simpleShort =
60+
new io.objectbox.Property<>(__INSTANCE, 3, 4, short.class, "simpleShort");
61+
62+
public final static io.objectbox.Property<TestEntity> simpleInt =
63+
new io.objectbox.Property<>(__INSTANCE, 4, 5, int.class, "simpleInt");
64+
65+
public final static io.objectbox.Property<TestEntity> simpleLong =
66+
new io.objectbox.Property<>(__INSTANCE, 5, 6, long.class, "simpleLong");
67+
68+
public final static io.objectbox.Property<TestEntity> simpleFloat =
69+
new io.objectbox.Property<>(__INSTANCE, 6, 7, float.class, "simpleFloat");
70+
71+
public final static io.objectbox.Property<TestEntity> simpleDouble =
72+
new io.objectbox.Property<>(__INSTANCE, 7, 8, double.class, "simpleDouble");
73+
74+
public final static io.objectbox.Property<TestEntity> simpleString =
75+
new io.objectbox.Property<>(__INSTANCE, 8, 9, String.class, "simpleString");
76+
77+
public final static io.objectbox.Property<TestEntity> simpleByteArray =
78+
new io.objectbox.Property<>(__INSTANCE, 9, 10, byte[].class, "simpleByteArray");
5779

5880
@SuppressWarnings("unchecked")
59-
public final static Property<TestEntity>[] __ALL_PROPERTIES = new Property[]{
81+
public final static io.objectbox.Property<TestEntity>[] __ALL_PROPERTIES = new io.objectbox.Property[]{
6082
id,
61-
simpleInt,
83+
simpleBoolean,
84+
simpleByte,
6285
simpleShort,
86+
simpleInt,
6387
simpleLong,
64-
simpleString,
6588
simpleFloat,
66-
simpleBoolean,
89+
simpleDouble,
90+
simpleString,
6791
simpleByteArray
6892
};
6993

70-
public final static Property<TestEntity> __ID_PROPERTY = id;
94+
public final static io.objectbox.Property<TestEntity> __ID_PROPERTY = id;
7195

7296
@Override
7397
public String getEntityName() {
7498
return __ENTITY_NAME;
7599
}
76100

77101
@Override
78-
public Class<TestEntity> getEntityClass() {
79-
return __ENTITY_CLASS;
102+
public int getEntityId() {
103+
return __ENTITY_ID;
80104
}
81105

82106
@Override
83-
public int getEntityId() {
84-
return 1;
107+
public Class<TestEntity> getEntityClass() {
108+
return __ENTITY_CLASS;
85109
}
86110

87111
@Override
@@ -90,12 +114,12 @@ public String getDbName() {
90114
}
91115

92116
@Override
93-
public Property<TestEntity>[] getAllProperties() {
117+
public io.objectbox.Property<TestEntity>[] getAllProperties() {
94118
return __ALL_PROPERTIES;
95119
}
96120

97121
@Override
98-
public Property<TestEntity> getIdProperty() {
122+
public io.objectbox.Property<TestEntity> getIdProperty() {
99123
return __ID_PROPERTY;
100124
}
101125

@@ -111,6 +135,7 @@ public CursorFactory<TestEntity> getCursorFactory() {
111135

112136
@Internal
113137
static final class TestEntityIdGetter implements IdGetter<TestEntity> {
138+
@Override
114139
public long getId(TestEntity object) {
115140
return object.getId();
116141
}

0 commit comments

Comments
 (0)