7
7
import io .weaviate .client6 .v1 .api .collections .config .WeaviateConfigClient ;
8
8
import io .weaviate .client6 .v1 .api .collections .data .WeaviateDataClient ;
9
9
import io .weaviate .client6 .v1 .api .collections .pagination .Paginator ;
10
+ import io .weaviate .client6 .v1 .api .collections .query .ConsistencyLevel ;
10
11
import io .weaviate .client6 .v1 .api .collections .query .WeaviateQueryClient ;
12
+ import io .weaviate .client6 .v1 .api .collections .tenants .WeaviateTenantsClient ;
11
13
import io .weaviate .client6 .v1 .internal .ObjectBuilder ;
12
14
import io .weaviate .client6 .v1 .internal .grpc .GrpcTransport ;
13
15
import io .weaviate .client6 .v1 .internal .orm .CollectionDescriptor ;
14
16
import io .weaviate .client6 .v1 .internal .rest .RestTransport ;
15
17
16
- public class CollectionHandle <T > {
18
+ public class CollectionHandle <PropertiesT > {
17
19
public final WeaviateConfigClient config ;
18
- public final WeaviateDataClient <T > data ;
19
- public final WeaviateQueryClient <T > query ;
20
+ public final WeaviateDataClient <PropertiesT > data ;
21
+ public final WeaviateQueryClient <PropertiesT > query ;
20
22
public final WeaviateAggregateClient aggregate ;
23
+ public final WeaviateTenantsClient tenants ;
24
+
25
+ private final CollectionHandleDefaults defaults ;
21
26
22
27
public CollectionHandle (
23
28
RestTransport restTransport ,
24
29
GrpcTransport grpcTransport ,
25
- CollectionDescriptor <T > collectionDescriptor ) {
30
+ CollectionDescriptor <PropertiesT > collection ,
31
+ CollectionHandleDefaults defaults ) {
32
+ this .config = new WeaviateConfigClient (collection , restTransport , grpcTransport , defaults );
33
+ this .aggregate = new WeaviateAggregateClient (collection , grpcTransport , defaults );
34
+ this .query = new WeaviateQueryClient <>(collection , grpcTransport , defaults );
35
+ this .data = new WeaviateDataClient <>(collection , restTransport , grpcTransport , defaults );
36
+ this .defaults = defaults ;
37
+
38
+ this .tenants = new WeaviateTenantsClient (collection , restTransport , grpcTransport );
39
+ }
40
+
41
+ /** Copy constructor that sets new defaults. */
42
+ private CollectionHandle (CollectionHandle <PropertiesT > c , CollectionHandleDefaults defaults ) {
43
+ this .config = new WeaviateConfigClient (c .config , defaults );
44
+ this .aggregate = new WeaviateAggregateClient (c .aggregate , defaults );
45
+ this .query = new WeaviateQueryClient <>(c .query , defaults );
46
+ this .data = new WeaviateDataClient <>(c .data , defaults );
47
+ this .defaults = defaults ;
26
48
27
- this .config = new WeaviateConfigClient (collectionDescriptor , restTransport , grpcTransport );
28
- this .data = new WeaviateDataClient <>(collectionDescriptor , restTransport , grpcTransport );
29
- this .query = new WeaviateQueryClient <>(collectionDescriptor , grpcTransport );
30
- this .aggregate = new WeaviateAggregateClient (collectionDescriptor , grpcTransport );
49
+ this .tenants = c .tenants ;
31
50
}
32
51
33
- public Paginator <T > paginate () {
52
+ public Paginator <PropertiesT > paginate () {
34
53
return Paginator .of (this .query );
35
54
}
36
55
37
- public Paginator <T > paginate (Function <Paginator .Builder <T >, ObjectBuilder <Paginator <T >>> fn ) {
56
+ public Paginator <PropertiesT > paginate (
57
+ Function <Paginator .Builder <PropertiesT >, ObjectBuilder <Paginator <PropertiesT >>> fn ) {
38
58
return Paginator .of (this .query , fn );
39
59
}
40
60
@@ -57,4 +77,25 @@ public Paginator<T> paginate(Function<Paginator.Builder<T>, ObjectBuilder<Pagina
57
77
public long size () {
58
78
return this .aggregate .overAll (all -> all .includeTotalCount (true )).totalCount ();
59
79
}
80
+
81
+ public ConsistencyLevel consistencyLevel () {
82
+ return defaults .consistencyLevel ();
83
+ }
84
+
85
+ public CollectionHandle <PropertiesT > withConsistencyLevel (ConsistencyLevel consistencyLevel ) {
86
+ return new CollectionHandle <>(this , CollectionHandleDefaults .of (with -> with .consistencyLevel (consistencyLevel )));
87
+ }
88
+
89
+ public String tenant () {
90
+ return defaults .tenant ();
91
+ }
92
+
93
+ public CollectionHandle <PropertiesT > withTenant (String tenant ) {
94
+ return new CollectionHandle <>(this , CollectionHandleDefaults .of (with -> with .tenant (tenant )));
95
+ }
96
+
97
+ public CollectionHandle <PropertiesT > withDefaults (
98
+ Function <CollectionHandleDefaults .Builder , ObjectBuilder <CollectionHandleDefaults >> fn ) {
99
+ return new CollectionHandle <>(this , CollectionHandleDefaults .of (fn ));
100
+ }
60
101
}
0 commit comments