15
15
*/
16
16
package org .springframework .data .mongodb .core ;
17
17
18
+ import java .util .Arrays ;
18
19
import java .util .List ;
19
20
import java .util .function .BiFunction ;
20
21
import java .util .function .Function ;
34
35
*/
35
36
class CollectionPreparerSupport implements ReadConcernAware , ReadPreferenceAware {
36
37
37
- final List <Object > sources ;
38
+ private final List <Object > sources ;
38
39
39
40
private CollectionPreparerSupport (List <Object > sources ) {
40
41
this .sources = sources ;
@@ -134,7 +135,8 @@ public static CollectionPreparerDelegate of(Object... mixedAwares) {
134
135
if (mixedAwares .length == 1 && mixedAwares [0 ] instanceof CollectionPreparerDelegate ) {
135
136
return (CollectionPreparerDelegate ) mixedAwares [0 ];
136
137
}
137
- return new CollectionPreparerDelegate (List .of (mixedAwares ));
138
+
139
+ return new CollectionPreparerDelegate (Arrays .asList (mixedAwares ));
138
140
}
139
141
140
142
@ Override
@@ -145,4 +147,36 @@ public MongoCollection<Document> prepare(MongoCollection<Document> collection) {
145
147
146
148
}
147
149
150
+ static class ReactiveCollectionPreparerDelegate extends CollectionPreparerSupport
151
+ implements CollectionPreparer <com .mongodb .reactivestreams .client .MongoCollection <Document >> {
152
+
153
+ private ReactiveCollectionPreparerDelegate (List <Object > sources ) {
154
+ super (sources );
155
+ }
156
+
157
+ public static ReactiveCollectionPreparerDelegate of (ReadPreferenceAware ... awares ) {
158
+ return of ((Object []) awares );
159
+ }
160
+
161
+ public static ReactiveCollectionPreparerDelegate of (Object ... mixedAwares ) {
162
+
163
+ if (mixedAwares .length == 1 && mixedAwares [0 ] instanceof CollectionPreparerDelegate ) {
164
+ return (ReactiveCollectionPreparerDelegate ) mixedAwares [0 ];
165
+ }
166
+
167
+ return new ReactiveCollectionPreparerDelegate (Arrays .asList (mixedAwares ));
168
+ }
169
+
170
+ @ Override
171
+ public com .mongodb .reactivestreams .client .MongoCollection <Document > prepare (
172
+ com .mongodb .reactivestreams .client .MongoCollection <Document > collection ) {
173
+ return doPrepare (collection , //
174
+ com .mongodb .reactivestreams .client .MongoCollection ::getReadConcern ,
175
+ com .mongodb .reactivestreams .client .MongoCollection ::withReadConcern ,
176
+ com .mongodb .reactivestreams .client .MongoCollection ::getReadPreference ,
177
+ com .mongodb .reactivestreams .client .MongoCollection ::withReadPreference );
178
+ }
179
+
180
+ }
181
+
148
182
}
0 commit comments