Skip to content

Commit 4e2a7d6

Browse files
committed
refactor: proofing AsyncResultSet
- this.cursor should be a final field since AsyncResult will only ever work with a single page - change currentPage access to package-private to avoid confusion See: #399 (comment)
1 parent 0cc1c6e commit 4e2a7d6

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/collections/pagination/AsyncResultSet.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.weaviate.client6.v1.api.collections.pagination;
22

33
import java.util.ArrayList;
4+
import java.util.Collections;
45
import java.util.Iterator;
56
import java.util.List;
67
import java.util.concurrent.CompletableFuture;
@@ -12,9 +13,9 @@
1213
public class AsyncResultSet<PropertiesT> implements Iterable<WeaviateObject<PropertiesT, Object, QueryMetadata>> {
1314

1415
private final int pageSize;
16+
private final String cursor;
1517
private final BiFunction<String, Integer, CompletableFuture<List<WeaviateObject<PropertiesT, Object, QueryMetadata>>>> fetch;
1618

17-
private String cursor;
1819
private List<WeaviateObject<PropertiesT, Object, QueryMetadata>> currentPage = new ArrayList<>();
1920

2021
AsyncResultSet(String cursor, int pageSize,
@@ -28,10 +29,10 @@ public class AsyncResultSet<PropertiesT> implements Iterable<WeaviateObject<Prop
2829
BiFunction<String, Integer, CompletableFuture<List<WeaviateObject<PropertiesT, Object, QueryMetadata>>>> fetch,
2930
List<WeaviateObject<PropertiesT, Object, QueryMetadata>> currentPage) {
3031
this(cursor, pageSize, fetch);
31-
this.currentPage = currentPage;
32+
this.currentPage = Collections.unmodifiableList(currentPage);
3233
}
3334

34-
public List<WeaviateObject<PropertiesT, Object, QueryMetadata>> currentPage() {
35+
List<WeaviateObject<PropertiesT, Object, QueryMetadata>> currentPage() {
3536
return currentPage;
3637
}
3738

0 commit comments

Comments
 (0)