3131import io .objectbox .BoxStore ;
3232import io .objectbox .InternalAccess ;
3333import io .objectbox .Property ;
34+ import io .objectbox .exception .NonUniqueResultException ;
3435import io .objectbox .reactive .DataObserver ;
3536import io .objectbox .reactive .DataSubscriptionList ;
3637import io .objectbox .reactive .SubscriptionBuilder ;
3738import io .objectbox .relation .RelationInfo ;
3839import io .objectbox .relation .ToOne ;
3940
4041/**
41- * A repeatable Query returning the latest matching Objects .
42+ * A repeatable Query returning the latest matching objects .
4243 * <p>
43- * Use {@link #find()} or related methods to fetch the latest results from the BoxStore.
44+ * Use {@link #find()} or related methods to fetch the latest results from the {@link BoxStore} .
4445 * <p>
4546 * Use {@link #property(Property)} to only return values or an aggregate of a single Property.
4647 * <p>
@@ -195,7 +196,12 @@ long cursorHandle() {
195196 }
196197
197198 /**
198- * Find the first Object matching the query.
199+ * Finds the first object matching this query.
200+ * <p>
201+ * Note: if no {@link QueryBuilder#order} conditions are present, which object is the first one might be arbitrary
202+ * (sometimes the one with the lowest ID, but never guaranteed to be).
203+ *
204+ * @return The first object if there are matches. {@code null} if no object matches.
199205 */
200206 @ Nullable
201207 public T findFirst () {
@@ -228,9 +234,10 @@ private void ensureNoComparator() {
228234 }
229235
230236 /**
231- * If there is a single matching object, returns it. If there is more than one matching object,
232- * throws {@link io.objectbox.exception.NonUniqueResultException NonUniqueResultException}.
233- * If there are no matches returns null.
237+ * Finds the only object matching this query.
238+ *
239+ * @return The object if a single object matches. {@code null} if no object matches. Throws
240+ * {@link NonUniqueResultException} if there are multiple objects matching the query.
234241 */
235242 @ Nullable
236243 public T findUnique () {
@@ -244,7 +251,12 @@ public T findUnique() {
244251 }
245252
246253 /**
247- * Find all Objects matching the query.
254+ * Finds objects matching the query.
255+ * <p>
256+ * Note: if no {@link QueryBuilder#order} conditions are present, the order is arbitrary (sometimes ordered by ID,
257+ * but never guaranteed to).
258+ *
259+ * @return A list of matching objects. An empty list if no object matches.
248260 */
249261 @ Nonnull
250262 public List <T > find () {
@@ -268,8 +280,12 @@ public List<T> find() {
268280 }
269281
270282 /**
271- * Find all Objects matching the query, skipping the first offset results and returning at most limit results.
272- * Use this for pagination.
283+ * Like {@link #find()}, but can skip and limit results.
284+ * <p>
285+ * Use to get a slice of the whole result, e.g. for "result paging".
286+ *
287+ * @param offset If greater than 0, skips this many results.
288+ * @param limit If greater than 0, returns at most this many results.
273289 */
274290 @ Nonnull
275291 public List <T > find (final long offset , final long limit ) {
@@ -282,46 +298,59 @@ public List<T> find(final long offset, final long limit) {
282298 }
283299
284300 /**
285- * Returns the ID of the first matching object. If there are no results returns 0 .
301+ * Like {@link #findFirst()}, but returns just the ID of the object .
286302 * <p>
287- * Like {@link #findFirst()}, but more efficient as no object is created.
303+ * This is more efficient as no object is created.
288304 * <p>
289305 * Ignores any {@link QueryBuilder#filter(QueryFilter) query filter}.
306+ *
307+ * @return The ID of the first matching object. {@code 0} if no object matches.
290308 */
291309 public long findFirstId () {
292310 checkOpen ();
293311 return box .internalCallWithReaderHandle (cursorHandle -> nativeFindFirstId (handle , cursorHandle ));
294312 }
295313
296314 /**
297- * If there is a single matching object, returns its ID. If there is more than one matching object,
298- * throws {@link io.objectbox.exception.NonUniqueResultException NonUniqueResultException}.
299- * If there are no matches returns 0.
315+ * Like {@link #findUnique()}, but returns just the ID of the object.
300316 * <p>
301- * Like {@link #findUnique()}, but more efficient as no object is created.
317+ * This is more efficient as no object is created.
302318 * <p>
303319 * Ignores any {@link QueryBuilder#filter(QueryFilter) query filter}.
320+ *
321+ * @return The ID of the object, if a single object matches. {@code 0} if no object matches. Throws
322+ * {@link NonUniqueResultException} if there are multiple objects matching the query.
304323 */
305324 public long findUniqueId () {
306325 checkOpen ();
307326 return box .internalCallWithReaderHandle (cursorHandle -> nativeFindUniqueId (handle , cursorHandle ));
308327 }
309328
310329 /**
311- * Very efficient way to get just the IDs without creating any objects. IDs can later be used to lookup objects
312- * (lookups by ID are also very efficient in ObjectBox).
330+ * Like {@link #find()}, but returns just the IDs of the objects.
331+ * <p>
332+ * IDs can later be used to {@link Box#get} objects.
333+ * <p>
334+ * This is very efficient as no objects are created.
313335 * <p>
314336 * Note: a filter set with {@link QueryBuilder#filter(QueryFilter)} will be silently ignored!
337+ *
338+ * @return An array of IDs of matching objects. An empty array if no objects match.
315339 */
316340 @ Nonnull
317341 public long [] findIds () {
318342 return findIds (0 , 0 );
319343 }
320344
321345 /**
322- * Like {@link #findIds()} but with a offset/limit param, e.g. for pagination.
346+ * Like {@link #findIds()}, but can skip and limit results.
347+ * <p>
348+ * Use to get a slice of the whole result, e.g. for "result paging".
323349 * <p>
324350 * Note: a filter set with {@link QueryBuilder#filter(QueryFilter)} will be silently ignored!
351+ *
352+ * @param offset If greater than 0, skips this many results.
353+ * @param limit If greater than 0, returns at most this many results.
325354 */
326355 @ Nonnull
327356 public long [] findIds (final long offset , final long limit ) {
0 commit comments