77import io .weaviate .client6 .v1 .api .collections .config .WeaviateConfigClient ;
88import io .weaviate .client6 .v1 .api .collections .data .WeaviateDataClient ;
99import io .weaviate .client6 .v1 .api .collections .pagination .Paginator ;
10+ import io .weaviate .client6 .v1 .api .collections .query .ConsistencyLevel ;
1011import io .weaviate .client6 .v1 .api .collections .query .WeaviateQueryClient ;
12+ import io .weaviate .client6 .v1 .api .collections .tenants .WeaviateTenantsClient ;
1113import io .weaviate .client6 .v1 .internal .ObjectBuilder ;
1214import io .weaviate .client6 .v1 .internal .grpc .GrpcTransport ;
1315import io .weaviate .client6 .v1 .internal .orm .CollectionDescriptor ;
1416import io .weaviate .client6 .v1 .internal .rest .RestTransport ;
1517
16- public class CollectionHandle <T > {
18+ public class CollectionHandle <PropertiesT > {
1719 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 ;
2022 public final WeaviateAggregateClient aggregate ;
23+ public final WeaviateTenantsClient tenants ;
24+
25+ private final CollectionHandleDefaults defaults ;
2126
2227 public CollectionHandle (
2328 RestTransport restTransport ,
2429 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 ;
2648
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 ;
3150 }
3251
33- public Paginator <T > paginate () {
52+ public Paginator <PropertiesT > paginate () {
3453 return Paginator .of (this .query );
3554 }
3655
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 ) {
3858 return Paginator .of (this .query , fn );
3959 }
4060
@@ -57,4 +77,25 @@ public Paginator<T> paginate(Function<Paginator.Builder<T>, ObjectBuilder<Pagina
5777 public long size () {
5878 return this .aggregate .overAll (all -> all .includeTotalCount (true )).totalCount ();
5979 }
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+ }
60101}
0 commit comments