Skip to content

Commit 0d7bc54

Browse files
committed
renaming refID to uid on Java side
1 parent 9bb3dc7 commit 0d7bc54

6 files changed

Lines changed: 38 additions & 39 deletions

File tree

objectbox-java-api/src/main/java/io/objectbox/annotation/Entity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Specifies the name on the DB side (e.g. table name) this entity maps to.
1818
* By default, the name is based on the entities class name.
1919
* <p>
20-
* Note: if you intent to rename an entity, consider using refId instead.
20+
* Note: if you intent to rename an entity, consider using uid instead.
2121
*/
2222
String nameInDb() default "";
2323

@@ -56,11 +56,11 @@
5656
// Class protobuf() default void.class;
5757

5858
/**
59-
* RefIDs identify entities (and properties) uniquely in the meta object model file (objectmodel.json).
60-
* With refIDs you can map entities to their meta model representation in a stable way without its name.
61-
* Once a refID is set, you can rename the entity as often as you like - ObjectBox keeps track of it automatically.
62-
* Thus, it is advisable to lookup the refID in objectmodel.json and use it here before renaming a entity.
59+
* UIDs identify entities (and properties) uniquely in the meta object model file (objectmodel.json).
60+
* With UIDs you can map entities to their meta model representation in a stable way without its name.
61+
* Once a UID is set, you can rename the entity as often as you like - ObjectBox keeps track of it automatically.
62+
* Thus, it is advisable to lookup the UID in objectmodel.json and use it here before renaming a entity.
6363
*/
64-
long refId() default 0;
64+
long uid() default 0;
6565

6666
}

objectbox-java-api/src/main/java/io/objectbox/annotation/Property.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
/**
1616
* Name of the database column for this property. Default is field name.
1717
* <p>
18-
* Note: if you intent to rename a property, consider using refId instead.
18+
* Note: if you intent to rename a property, consider using uid instead.
1919
*/
2020
String nameInDb() default "";
2121

22-
2322
/**
24-
* RefIDs identify properties (and entities) uniquely in the meta object model file (objectmodel.json).
25-
* With refIDs you can map properties to their meta model representation in a stable way without its name.
26-
* Once a refID is set, you can rename the properties as often as you like - ObjectBox keeps track of it automatically.
27-
* Thus, it is advisable to lookup the refID in objectmodel.json and use it here before renaming a property.
23+
* UIDs identify properties (and entities) uniquely in the meta object model file (objectmodel.json).
24+
* With UIDs you can map properties to their meta model representation in a stable way without its name.
25+
* Once a UID is set, you can rename the properties as often as you like - ObjectBox keeps track of it automatically.
26+
* Thus, it is advisable to lookup the UID in objectmodel.json and use it here before renaming a property.
2827
*/
29-
long refId() default 0;
28+
long uid() default 0;
3029
}

objectbox-java/src/main/java/io/objectbox/ModelBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public PropertyBuilder indexId(int indexId) {
4949
return this;
5050
}
5151

52-
public PropertyBuilder refId(long refId) {
52+
public PropertyBuilder uid(long refId) {
5353
checkNotFinished();
54-
ModelProperty.addRefId(fbb, refId);
54+
ModelProperty.addUid(fbb, refId);
5555
return this;
5656
}
5757

objectbox-java/src/main/java/io/objectbox/model/ModelProperty.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import java.nio.*;
66
import java.lang.*;
7-
import java.util.*;
7+
88
import com.google.flatbuffers.*;
99

1010
@SuppressWarnings("unused")
@@ -42,7 +42,7 @@ public static int createModelProperty(FlatBufferBuilder builder,
4242
long indexId,
4343
int targetEntityOffset) {
4444
builder.startObject(7);
45-
ModelProperty.addRefId(builder, refId);
45+
ModelProperty.addUid(builder, refId);
4646
ModelProperty.addTargetEntity(builder, targetEntityOffset);
4747
ModelProperty.addIndexId(builder, indexId);
4848
ModelProperty.addFlags(builder, flags);
@@ -54,7 +54,7 @@ public static int createModelProperty(FlatBufferBuilder builder,
5454

5555
public static void startModelProperty(FlatBufferBuilder builder) { builder.startObject(7); }
5656
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(0, nameOffset, 0); }
57-
public static void addRefId(FlatBufferBuilder builder, long refId) { builder.addLong(1, refId, 0L); }
57+
public static void addUid(FlatBufferBuilder builder, long refId) { builder.addLong(1, refId, 0L); }
5858
public static void addId(FlatBufferBuilder builder, long id) { builder.addInt(2, (int)id, (int)0L); }
5959
public static void addType(FlatBufferBuilder builder, int type) { builder.addShort(3, (short)type, (short)0); }
6060
public static void addFlags(FlatBufferBuilder builder, long flags) { builder.addInt(4, (int)flags, (int)0L); }

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class AbstractObjectBoxTest {
2424
protected boolean runExtensiveTests;
2525
int lastEntityId;
2626
int lastIndexId;
27-
long lastRefId;
27+
long lastUid;
2828

2929
@Before
3030
public void setUp() throws IOException {
@@ -152,28 +152,28 @@ byte[] createTestModelWithTwoEntities(boolean withIndex) {
152152
}
153153

154154
private void addTestEntity(ModelBuilder modelBuilder, boolean withIndex) {
155-
EntityBuilder entityBuilder = modelBuilder.entity("TestEntity").id(++lastEntityId).refId(++lastRefId);
155+
EntityBuilder entityBuilder = modelBuilder.entity("TestEntity").id(++lastEntityId).refId(++lastUid);
156156
int pId = 0;
157-
entityBuilder.property("id", PropertyType.Long).id(++pId).refId(++lastRefId).flags(PropertyFlags.ID);
158-
entityBuilder.property("simpleBoolean", PropertyType.Bool).id(++pId).refId(++lastRefId);
159-
entityBuilder.property("simpleByte", PropertyType.Byte).id(++pId).refId(++lastRefId);
160-
entityBuilder.property("simpleShort", PropertyType.Short).id(++pId).refId(++lastRefId);
161-
entityBuilder.property("simpleInt", PropertyType.Int).id(++pId).refId(++lastRefId);
162-
entityBuilder.property("simpleLong", PropertyType.Long).id(++pId).refId(++lastRefId);
163-
entityBuilder.property("simpleFloat", PropertyType.Float).id(++pId).refId(++lastRefId);
164-
entityBuilder.property("simpleDouble", PropertyType.Double).id(++pId).refId(++lastRefId);
165-
entityBuilder.property("simpleString", PropertyType.String).id(++pId).refId(++lastRefId)
157+
entityBuilder.property("id", PropertyType.Long).id(++pId).uid(++lastUid).flags(PropertyFlags.ID);
158+
entityBuilder.property("simpleBoolean", PropertyType.Bool).id(++pId).uid(++lastUid);
159+
entityBuilder.property("simpleByte", PropertyType.Byte).id(++pId).uid(++lastUid);
160+
entityBuilder.property("simpleShort", PropertyType.Short).id(++pId).uid(++lastUid);
161+
entityBuilder.property("simpleInt", PropertyType.Int).id(++pId).uid(++lastUid);
162+
entityBuilder.property("simpleLong", PropertyType.Long).id(++pId).uid(++lastUid);
163+
entityBuilder.property("simpleFloat", PropertyType.Float).id(++pId).uid(++lastUid);
164+
entityBuilder.property("simpleDouble", PropertyType.Double).id(++pId).uid(++lastUid);
165+
entityBuilder.property("simpleString", PropertyType.String).id(++pId).uid(++lastUid)
166166
.flags(withIndex ? PropertyFlags.INDEXED : 0).indexId(withIndex ? ++lastIndexId : 0);
167-
entityBuilder.property("simpleByteArray", PropertyType.ByteVector).id(++pId).refId(++lastRefId);
167+
entityBuilder.property("simpleByteArray", PropertyType.ByteVector).id(++pId).uid(++lastUid);
168168
entityBuilder.lastPropertyId(pId);
169169
entityBuilder.entityDone();
170170
}
171171

172172
private void addTestEntityMinimal(ModelBuilder modelBuilder, boolean withIndex) {
173-
EntityBuilder entityBuilder = modelBuilder.entity("TestEntityMinimal").id(++lastEntityId).refId(++lastRefId);
173+
EntityBuilder entityBuilder = modelBuilder.entity("TestEntityMinimal").id(++lastEntityId).refId(++lastUid);
174174
int pId = 0;
175-
entityBuilder.property("id", PropertyType.Long).id(++pId).refId(++lastRefId).flags(PropertyFlags.ID);
176-
entityBuilder.property("text", PropertyType.String).id(++pId).refId(++lastRefId)
175+
entityBuilder.property("id", PropertyType.Long).id(++pId).uid(++lastUid).flags(PropertyFlags.ID);
176+
entityBuilder.property("text", PropertyType.String).id(++pId).uid(++lastUid)
177177
.flags(withIndex ? PropertyFlags.INDEXED : 0).indexId(withIndex ? ++lastIndexId : 0);
178178
entityBuilder.lastPropertyId(pId);
179179
entityBuilder.entityDone();

tests/objectbox-java-test/src/main/java/io/objectbox/relation/MyObjectBox.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ private static byte[] getModel() {
3333

3434
entityBuilder = modelBuilder.entity("Customer");
3535
entityBuilder.id(1).refId(3625336331812221361L).lastPropertyId(2);
36-
entityBuilder.property("_id", PropertyType.Long).id(1).refId(1582995887554488290L)
36+
entityBuilder.property("_id", PropertyType.Long).id(1).uid(1582995887554488290L)
3737
.flags(PropertyFlags.ID | PropertyFlags.NOT_NULL);
38-
entityBuilder.property("name", PropertyType.String).id(2).refId(3080561794084640807L)
38+
entityBuilder.property("name", PropertyType.String).id(2).uid(3080561794084640807L)
3939
.flags(PropertyFlags.INDEXED).indexId(1);
4040
entityBuilder.entityDone();
4141

4242

4343
entityBuilder = modelBuilder.entity("ORDERS");
4444
entityBuilder.id(3).refId(4761318278698541254L).lastPropertyId(4);
45-
entityBuilder.property("_id", PropertyType.Long).id(1).refId(4065349512068827171L)
45+
entityBuilder.property("_id", PropertyType.Long).id(1).uid(4065349512068827171L)
4646
.flags(PropertyFlags.ID | PropertyFlags.ID_SELF_ASSIGNABLE | PropertyFlags.NOT_NULL);
47-
entityBuilder.property("date", PropertyType.Date).id(2).refId(1517800508838480650L);
48-
entityBuilder.property("customerId", "Customer", PropertyType.Relation).id(3).refId(7549816757665526666L)
47+
entityBuilder.property("date", PropertyType.Date).id(2).uid(1517800508838480650L);
48+
entityBuilder.property("customerId", "Customer", PropertyType.Relation).id(3).uid(7549816757665526666L)
4949
.flags(PropertyFlags.NOT_NULL | PropertyFlags.INDEXED | PropertyFlags.INDEX_PARTIAL_SKIP_ZERO).indexId(2);
50-
entityBuilder.property("text", PropertyType.String).id(4).refId(4188485512096015343L);
50+
entityBuilder.property("text", PropertyType.String).id(4).uid(4188485512096015343L);
5151
entityBuilder.entityDone();
5252

5353
return modelBuilder.build();

0 commit comments

Comments
 (0)