@@ -264,9 +264,10 @@ private void ensureEntities() {
264
264
}
265
265
266
266
/**
267
- * Adds the given entity to the list and tracks the addition so it can be later applied to the database
268
- * (e.g. via {@link Box#put(Object)} of the entity owning the ToMany, or via {@link #applyChangesToDb()}).
269
- * Note that the given entity will remain unchanged at this point (e.g. to-ones are not updated).
267
+ * Prepares to add the given target object to this relation.
268
+ * <p>
269
+ * To apply changes, call {@link #applyChangesToDb()} or put the object with the ToMany. For important details, see
270
+ * the notes about relations of {@link Box#put(Object)}.
270
271
*/
271
272
@ Override
272
273
public synchronized boolean add (TARGET object ) {
@@ -367,8 +368,9 @@ public boolean containsAll(Collection<?> collection) {
367
368
}
368
369
369
370
/**
370
- * @return An object for the given ID, or null if the object was already removed from its box
371
- * (and was not cached before).
371
+ * Gets the target object at the given index.
372
+ * <p>
373
+ * {@link ToMany} uses lazy initialization, so on first access this will read the target objects from the database.
372
374
*/
373
375
@ Override
374
376
public TARGET get (int location ) {
@@ -419,6 +421,9 @@ public ListIterator<TARGET> listIterator(int location) {
419
421
return entities .listIterator (location );
420
422
}
421
423
424
+ /**
425
+ * Like {@link #remove(Object)}, but using the location of the target object.
426
+ */
422
427
@ Override
423
428
public synchronized TARGET remove (int location ) {
424
429
ensureEntitiesWithTrackingLists ();
@@ -427,6 +432,12 @@ public synchronized TARGET remove(int location) {
427
432
return removed ;
428
433
}
429
434
435
+ /**
436
+ * Prepares to remove the target object from this relation.
437
+ * <p>
438
+ * To apply changes, call {@link #applyChangesToDb()} or put the object with the ToMany. For important details, see
439
+ * the notes about relations of {@link Box#put(Object)}.
440
+ */
430
441
@ SuppressWarnings ("unchecked" ) // Cast to TARGET: If removed, must be of type TARGET.
431
442
@ Override
432
443
public synchronized boolean remove (Object object ) {
@@ -438,7 +449,9 @@ public synchronized boolean remove(Object object) {
438
449
return removed ;
439
450
}
440
451
441
- /** Removes an object by its entity ID. */
452
+ /**
453
+ * Like {@link #remove(Object)}, but using just the ID of the target object.
454
+ */
442
455
public synchronized TARGET removeById (long id ) {
443
456
ensureEntities ();
444
457
int size = entities .size ();
0 commit comments