Skip to content

Commit 8ae58c3

Browse files
committed
added secondaryName to PropertyBuilder
1 parent 46bd877 commit 8ae58c3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ public class ModelBuilder {
4848
Long lastRelationUid;
4949

5050
public class PropertyBuilder {
51+
/** Deferred, so we can still add strings after constructor. */
52+
private final int type;
5153
boolean finished;
5254

5355
PropertyBuilder(String name, String targetEntityName, String virtualTarget, int type) {
56+
this.type = type;
5457
int propertyNameOffset = fbb.createString(name);
5558
int targetEntityOffset = targetEntityName != null ? fbb.createString(targetEntityName) : 0;
5659
int virtualTargetOffset = virtualTarget != null ? fbb.createString(virtualTarget) : 0;
@@ -62,7 +65,6 @@ public class PropertyBuilder {
6265
if (virtualTargetOffset != 0) {
6366
ModelProperty.addVirtualTarget(fbb, virtualTargetOffset);
6467
}
65-
ModelProperty.addType(fbb, type);
6668
}
6769

6870
public PropertyBuilder id(int id, long uid) {
@@ -85,6 +87,15 @@ public PropertyBuilder flags(int flags) {
8587
return this;
8688
}
8789

90+
public PropertyBuilder secondaryName(String secondaryName) {
91+
checkNotFinished();
92+
if (secondaryName != null) {
93+
int offset = fbb.createString(secondaryName);
94+
ModelProperty.addNameSecondary(fbb, offset);
95+
}
96+
return this;
97+
}
98+
8899
private void checkNotFinished() {
89100
if (finished) {
90101
throw new IllegalStateException("Already finished");
@@ -94,6 +105,7 @@ private void checkNotFinished() {
94105
public int finish() {
95106
checkNotFinished();
96107
finished = true;
108+
ModelProperty.addType(fbb, type);
97109
return ModelProperty.endModelProperty(fbb);
98110
}
99111
}

0 commit comments

Comments
 (0)