Skip to content

Commit 97e0584

Browse files
ToMany: correctly refer to object instead of entity where needed
1 parent a758a0e commit 97e0584

File tree

1 file changed

+19
-19
lines changed
  • objectbox-java/src/main/java/io/objectbox/relation

1 file changed

+19
-19
lines changed

objectbox-java/src/main/java/io/objectbox/relation/ToMany.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ private void ensureBoxes() {
193193
try {
194194
boxStore = (BoxStore) boxStoreField.get(entity);
195195
if (boxStore == null) {
196-
throw new DbDetachedException("Cannot resolve relation for detached entities, " +
197-
"call box.attach(entity) beforehand.");
196+
throw new DbDetachedException("Cannot resolve relation for detached objects, " +
197+
"call box.attach(object) beforehand.");
198198
}
199199
} catch (IllegalAccessException e) {
200200
throw new RuntimeException(e);
@@ -570,9 +570,9 @@ public int getRemoveCount() {
570570
}
571571

572572
/**
573-
* Sorts the list by the "natural" ObjectBox order for to-many list (by entity ID).
574-
* This will be the order when you get the entities fresh (e.g. initially or after calling {@link #reset()}).
575-
* Note that non persisted entities (ID is zero) will be put to the end as they are still to get an ID.
573+
* Sorts the list by the "natural" ObjectBox order for to-many list (by object ID).
574+
* This will be the order when you get the objects fresh (e.g. initially or after calling {@link #reset()}).
575+
* Note that non persisted objects (ID is zero) will be put to the end as they are still to get an ID.
576576
*/
577577
public void sortById() {
578578
ensureEntities();
@@ -601,7 +601,7 @@ else if (delta > 0)
601601
}
602602

603603
/**
604-
* Saves changes (added and removed entities) made to this relation to the database. For some important details, see
604+
* Saves changes (added and removed objects) made to this relation to the database. For some important details, see
605605
* the notes about relations of {@link Box#put(Object)}.
606606
* <p>
607607
* Note that this is called already when the object that contains this ToMany is put. However, if only this ToMany
@@ -614,12 +614,12 @@ public void applyChangesToDb() {
614614
long id = relationInfo.sourceInfo.getIdGetter().getId(entity);
615615
if (id == 0) {
616616
throw new IllegalStateException(
617-
"The source entity was not yet persisted (no ID), use box.put() on it instead");
617+
"The object with the ToMany was not yet persisted (no ID), use box.put() on it instead");
618618
}
619619
try {
620620
ensureBoxes();
621621
} catch (DbDetachedException e) {
622-
throw new IllegalStateException("The source entity was not yet persisted, use box.put() on it instead");
622+
throw new IllegalStateException("The object with the ToMany was not yet persisted, use box.put() on it instead");
623623
}
624624
if (internalCheckApplyToDbRequired()) {
625625
// We need a TX because we use two writers and both must use same TX (without: unchecked, SIGSEGV)
@@ -632,10 +632,10 @@ public void applyChangesToDb() {
632632
}
633633

634634
/**
635-
* Returns true if at least one of the entities matches the given filter.
635+
* Returns true if at least one of the target objects matches the given filter.
636636
* <p>
637637
* For use with {@link QueryBuilder#filter(QueryFilter)} inside a {@link QueryFilter} to check
638-
* to-many relation entities.
638+
* to-many relation objects.
639639
*/
640640
@Beta
641641
public boolean hasA(QueryFilter<TARGET> filter) {
@@ -650,10 +650,10 @@ public boolean hasA(QueryFilter<TARGET> filter) {
650650
}
651651

652652
/**
653-
* Returns true if all of the entities match the given filter. Returns false if the list is empty.
653+
* Returns true if all of the target objects match the given filter. Returns false if the list is empty.
654654
* <p>
655655
* For use with {@link QueryBuilder#filter(QueryFilter)} inside a {@link QueryFilter} to check
656-
* to-many relation entities.
656+
* to-many relation objects.
657657
*/
658658
@Beta
659659
public boolean hasAll(QueryFilter<TARGET> filter) {
@@ -670,7 +670,7 @@ public boolean hasAll(QueryFilter<TARGET> filter) {
670670
return true;
671671
}
672672

673-
/** Gets an object by its entity ID. */
673+
/** Gets an object by its ID. */
674674
@Beta
675675
public TARGET getById(long id) {
676676
ensureEntities();
@@ -685,7 +685,7 @@ public TARGET getById(long id) {
685685
return null;
686686
}
687687

688-
/** Gets the index of the object with the given entity ID. */
688+
/** Gets the index of the object with the given ID. */
689689
@Beta
690690
public int indexOfId(long id) {
691691
ensureEntities();
@@ -704,7 +704,7 @@ public int indexOfId(long id) {
704704

705705
/**
706706
* Returns true if there are pending changes for the DB.
707-
* Changes will be automatically persisted once the owning entity is put, or an explicit call to
707+
* Changes will be automatically persisted once the object with the ToMany is put, or an explicit call to
708708
* {@link #applyChangesToDb()} is made.
709709
*/
710710
public boolean hasPendingDbChanges() {
@@ -719,7 +719,7 @@ public boolean hasPendingDbChanges() {
719719

720720
/**
721721
* For internal use only; do not use in your app.
722-
* Called after relation source entity is put (so we have its ID).
722+
* Called after relation source object is put (so we have its ID).
723723
* Prepares data for {@link #internalApplyToDb(Cursor, Cursor)}
724724
*/
725725
@Internal
@@ -743,7 +743,7 @@ public boolean internalCheckApplyToDbRequired() {
743743
// Relation based on Backlink
744744
long entityId = relationInfo.sourceInfo.getIdGetter().getId(entity);
745745
if (entityId == 0) {
746-
throw new IllegalStateException("Source entity has no ID (should have been put before)");
746+
throw new IllegalStateException("Object with the ToMany has no ID (should have been put before)");
747747
}
748748
IdGetter<TARGET> idGetter = relationInfo.targetInfo.getIdGetter();
749749
Map<TARGET, Boolean> setAdded = this.entitiesAdded;
@@ -917,7 +917,7 @@ public void internalApplyToDb(Cursor<?> sourceCursor, Cursor<TARGET> targetCurso
917917
if (isStandaloneRelation) {
918918
long entityId = relationInfo.sourceInfo.getIdGetter().getId(entity);
919919
if (entityId == 0) {
920-
throw new IllegalStateException("Source entity has no ID (should have been put before)");
920+
throw new IllegalStateException("Object with the ToMany has no ID (should have been put before)");
921921
}
922922

923923
if (removedStandalone != null) {
@@ -960,7 +960,7 @@ private void addStandaloneRelations(Cursor<?> cursor, long sourceEntityId, TARGE
960960
long targetId = targetIdGetter.getId(added[i]);
961961
if (targetId == 0) {
962962
// Paranoia
963-
throw new IllegalStateException("Target entity has no ID (should have been put before)");
963+
throw new IllegalStateException("Target object has no ID (should have been put before)");
964964
}
965965
targetIds[i] = targetId;
966966
}

0 commit comments

Comments
 (0)