Skip to content

Commit 228369a

Browse files
committed
Improve param name and doc
1 parent dac7d2b commit 228369a

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

datastore/src/main/java/io/spine/server/storage/datastore/DatastoreWrapper.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,29 +255,29 @@ public Entity read(Key key) {
255255
* <p>The Datastore may return a partial result set, so an execution of this method may
256256
* result in several Datastore queries.
257257
*
258-
* <p>The limit included in the {@link StructuredQuery}, will be a maximum count of entities
258+
* <p>The limit included in the {@link StructuredQuery}, will be a maximum count of objects
259259
* in the returned iterator.
260260
*
261261
* <p>The returned {@link DsQueryIterator} allows to {@linkplain DsQueryIterator#nextPageQuery()
262-
* create a query} to the next page of entities reusing an existing cursor.
262+
* create a query} to the next page of results reusing an existing cursor.
263263
*
264264
* <p>The resulting {@code Iterator} is evaluated lazily. A call to
265265
* {@link Iterator#remove() Iterator.remove()} causes an {@link UnsupportedOperationException}.
266266
*
267267
* @param query
268268
* {@link Query} to execute upon the Datastore
269-
* @param <E>
269+
* @param <R>
270270
* the type of queried objects
271271
* @return results fo the query as a lazily evaluated {@link Iterator}
272272
* @see DatastoreReader#run(Query)
273273
*/
274-
public <E> DsQueryIterator<E> read(StructuredQuery<E> query) {
274+
public <R> DsQueryIterator<R> read(StructuredQuery<R> query) {
275275
Namespace namespace = currentNamespace();
276-
StructuredQuery<E> queryWithNamespace =
276+
StructuredQuery<R> queryWithNamespace =
277277
query.toBuilder()
278278
.setNamespace(namespace.getValue())
279279
.build();
280-
DsQueryIterator<E> result = new DsQueryIterator<>(queryWithNamespace, actor);
280+
DsQueryIterator<R> result = new DsQueryIterator<>(queryWithNamespace, actor);
281281
return result;
282282
}
283283

@@ -294,13 +294,13 @@ public <E> DsQueryIterator<E> read(StructuredQuery<E> query) {
294294
* {@link Query} to execute upon the Datastore
295295
* @param pageSize
296296
* a non-zero number of elements to be returned per a single read from Datastore
297-
* @param <E>
297+
* @param <R>
298298
* the type of queried objects
299299
* @return results fo the query as a lazily evaluated {@link Iterator}
300300
* @throws IllegalArgumentException
301301
* if the provided {@linkplain StructuredQuery#getLimit() query includes a limit}
302302
*/
303-
<E> Iterator<E> readAll(StructuredQuery<E> query, int pageSize) {
303+
<R> Iterator<R> readAll(StructuredQuery<R> query, int pageSize) {
304304
return readAllPageByPage(query, pageSize);
305305
}
306306

@@ -315,13 +315,13 @@ <E> Iterator<E> readAll(StructuredQuery<E> query, int pageSize) {
315315
*
316316
* @param query
317317
* {@link Query} to execute upon the Datastore
318-
* @param <E>
318+
* @param <R>
319319
* the type of queried objects
320320
* @return results fo the query as a lazily evaluated {@link Iterator}
321321
* @throws IllegalArgumentException
322322
* if the provided {@linkplain StructuredQuery#getLimit() query includes a limit}
323323
*/
324-
<E> Iterator<E> readAll(StructuredQuery<E> query) {
324+
<R> Iterator<R> readAll(StructuredQuery<R> query) {
325325
return readAllPageByPage(query, null);
326326
}
327327

@@ -339,28 +339,28 @@ <E> Iterator<E> readAll(StructuredQuery<E> query) {
339339
* @param pageSize
340340
* a non-zero number of elements to be returned per a single read from Datastore;
341341
* if {@code null} the page size will be dictated by the Datastore
342-
* @param <E>
342+
* @param <R>
343343
* the type of queried objects
344344
* @return results fo the query as a lazily evaluated {@link Iterator}
345345
* @throws IllegalArgumentException
346346
* if the provided {@linkplain StructuredQuery#getLimit() query includes a limit} or
347347
* the provided {@code batchSize} is 0
348348
*/
349349
@SuppressWarnings("unchecked") // Checked logically.
350-
private <E> Iterator<E>
351-
readAllPageByPage(StructuredQuery<E> query, @Nullable Integer pageSize) {
350+
private <R> Iterator<R>
351+
readAllPageByPage(StructuredQuery<R> query, @Nullable Integer pageSize) {
352352
checkArgument(query.getLimit() == null,
353353
"Cannot limit a number of entities for \"read all\" operation.");
354354
checkArgument(pageSize == null || pageSize != 0,
355355
"The size of a single read operation cannot be 0.");
356356

357-
StructuredQuery<E> limitedQuery = limit(query, pageSize);
357+
StructuredQuery<R> limitedQuery = limit(query, pageSize);
358358
return stream(new DsQueryPageIterator<>(limitedQuery, this))
359359
.flatMap(Streams::stream)
360360
.iterator();
361361
}
362362

363-
private static <E> StructuredQuery<E> limit(StructuredQuery<E> query,
363+
private static <R> StructuredQuery<R> limit(StructuredQuery<R> query,
364364
@Nullable Integer batchSize) {
365365
return batchSize == null
366366
? query

datastore/src/main/java/io/spine/server/storage/datastore/DsQueryIterator.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@
4444
*
4545
* <p>The {@link #remove() remove()} method throws an {@link UnsupportedOperationException}.
4646
*
47-
* @param <E>
47+
* @param <R>
4848
* the type of queried objects
4949
*/
50-
final class DsQueryIterator<E> extends UnmodifiableIterator<E> {
50+
final class DsQueryIterator<R> extends UnmodifiableIterator<R> {
5151

52-
private final StructuredQuery<E> query;
53-
private final QueryResults<E> currentPage;
52+
private final StructuredQuery<R> query;
53+
private final QueryResults<R> currentPage;
5454

5555
private final Integer limit;
5656
private int readCount = 0;
5757

5858
private boolean terminated;
5959

60-
DsQueryIterator(StructuredQuery<E> query, DatastoreReaderWriter datastore) {
60+
DsQueryIterator(StructuredQuery<R> query, DatastoreReaderWriter datastore) {
6161
super();
6262
this.query = query;
6363
this.limit = query.getLimit();
@@ -94,21 +94,21 @@ private void terminate() {
9494
* <p>The query is built utilizing the {@linkplain Cursor Datastore Cursor} from the current
9595
* query results.
9696
*/
97-
StructuredQuery<E> nextPageQuery() {
97+
StructuredQuery<R> nextPageQuery() {
9898
Cursor cursorAfter = currentPage.getCursorAfter();
99-
StructuredQuery<E> queryForMoreResults =
99+
StructuredQuery<R> queryForMoreResults =
100100
query.toBuilder()
101101
.setStartCursor(cursorAfter)
102102
.build();
103103
return queryForMoreResults;
104104
}
105105

106106
@Override
107-
public E next() {
107+
public R next() {
108108
if (!hasNext()) {
109109
throw new NoSuchElementException("The query results Iterator is empty.");
110110
}
111-
E result = currentPage.next();
111+
R result = currentPage.next();
112112
readCount++;
113113
return result;
114114
}

datastore/src/main/java/io/spine/server/storage/datastore/DsQueryPageIterator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@
3939
* <p>If the limit is not specified, then the page size is determined by the Datastore
4040
* query restrictions.
4141
*
42-
* @param <E>
42+
* @param <R>
4343
* the type of queried objects
4444
*/
45-
final class DsQueryPageIterator<E> implements Iterator<DsQueryIterator> {
45+
final class DsQueryPageIterator<R> implements Iterator<DsQueryIterator> {
4646

4747
private final DatastoreWrapper datastore;
4848

49-
private DsQueryIterator<E> currentPage;
50-
private @Nullable DsQueryIterator<E> nextPage;
49+
private DsQueryIterator<R> currentPage;
50+
private @Nullable DsQueryIterator<R> nextPage;
5151

52-
DsQueryPageIterator(StructuredQuery<E> query, DatastoreWrapper datastore) {
52+
DsQueryPageIterator(StructuredQuery<R> query, DatastoreWrapper datastore) {
5353
this.datastore = datastore;
5454
this.currentPage = datastore.read(query);
5555
}
@@ -63,7 +63,7 @@ public boolean hasNext() {
6363
}
6464

6565
@Override
66-
public DsQueryIterator<E> next() {
66+
public DsQueryIterator<R> next() {
6767
if (nextPage == null) {
6868
currentPage = loadNextPage();
6969
} else {
@@ -76,8 +76,8 @@ public DsQueryIterator<E> next() {
7676
return currentPage;
7777
}
7878

79-
private DsQueryIterator<E> loadNextPage() {
80-
StructuredQuery<E> nextPageQuery = currentPage.nextPageQuery();
79+
private DsQueryIterator<R> loadNextPage() {
80+
StructuredQuery<R> nextPageQuery = currentPage.nextPageQuery();
8181
return datastore.read(nextPageQuery);
8282
}
8383
}

0 commit comments

Comments
 (0)