|
21 | 21 | import java.util.ArrayList;
|
22 | 22 | import java.util.List;
|
23 | 23 |
|
| 24 | +import javax.annotation.Nullable; |
| 25 | + |
24 | 26 | import io.objectbox.annotation.apihint.Internal;
|
25 | 27 | import io.objectbox.model.IdUid;
|
26 | 28 | import io.objectbox.model.Model;
|
|
29 | 31 | import io.objectbox.model.ModelRelation;
|
30 | 32 |
|
31 | 33 | // Remember: IdUid is a struct, not a table, and thus must be inlined
|
| 34 | +@SuppressWarnings("WeakerAccess,UnusedReturnValue, unused") |
32 | 35 | @Internal
|
33 | 36 | public class ModelBuilder {
|
34 | 37 | private static final int MODEL_VERSION = 2;
|
@@ -61,7 +64,7 @@ public class PropertyBuilder {
|
61 | 64 | private int indexId;
|
62 | 65 | private long indexUid;
|
63 | 66 |
|
64 |
| - PropertyBuilder(String name, String targetEntityName, String virtualTarget, int type) { |
| 67 | + PropertyBuilder(String name, @Nullable String targetEntityName, @Nullable String virtualTarget, int type) { |
65 | 68 | this.type = type;
|
66 | 69 | propertyNameOffset = fbb.createString(name);
|
67 | 70 | targetEntityOffset = targetEntityName != null ? fbb.createString(targetEntityName) : 0;
|
@@ -90,9 +93,7 @@ public PropertyBuilder flags(int flags) {
|
90 | 93 |
|
91 | 94 | public PropertyBuilder secondaryName(String secondaryName) {
|
92 | 95 | checkNotFinished();
|
93 |
| - if (secondaryName != null) { |
94 |
| - secondaryNameOffset = fbb.createString(secondaryName); |
95 |
| - } |
| 96 | + secondaryNameOffset = fbb.createString(secondaryName); |
96 | 97 | return this;
|
97 | 98 | }
|
98 | 99 |
|
@@ -178,11 +179,12 @@ public PropertyBuilder property(String name, int type) {
|
178 | 179 | return property(name, null, type);
|
179 | 180 | }
|
180 | 181 |
|
181 |
| - public PropertyBuilder property(String name, String targetEntityName, int type) { |
| 182 | + public PropertyBuilder property(String name, @Nullable String targetEntityName, int type) { |
182 | 183 | return property(name, targetEntityName, null, type);
|
183 | 184 | }
|
184 | 185 |
|
185 |
| - public PropertyBuilder property(String name, String targetEntityName, String virtualTarget, int type) { |
| 186 | + public PropertyBuilder property(String name, @Nullable String targetEntityName, @Nullable String virtualTarget, |
| 187 | + int type) { |
186 | 188 | checkNotFinished();
|
187 | 189 | checkFinishProperty();
|
188 | 190 | propertyBuilder = new PropertyBuilder(name, targetEntityName, virtualTarget, type);
|
@@ -226,7 +228,7 @@ public ModelBuilder entityDone() {
|
226 | 228 | ModelEntity.addName(fbb, testEntityNameOffset);
|
227 | 229 | ModelEntity.addProperties(fbb, propertiesOffset);
|
228 | 230 | if (relationsOffset != 0) ModelEntity.addRelations(fbb, relationsOffset);
|
229 |
| - if (id != null || uid != null) { |
| 231 | + if (id != null && uid != null) { |
230 | 232 | int idOffset = IdUid.createIdUid(fbb, id, uid);
|
231 | 233 | ModelEntity.addId(fbb, idOffset);
|
232 | 234 | }
|
|
0 commit comments