17
17
18
18
import static org .springframework .data .mongodb .core .query .Criteria .*;
19
19
20
+ import reactor .core .publisher .Flux ;
21
+ import reactor .core .publisher .Mono ;
22
+
20
23
import java .io .Serializable ;
21
24
import java .util .ArrayList ;
22
25
import java .util .Collection ;
35
38
import org .springframework .data .mongodb .repository .query .MongoEntityInformation ;
36
39
import org .springframework .util .Assert ;
37
40
38
- import reactor .core .publisher .Flux ;
39
- import reactor .core .publisher .Mono ;
40
-
41
41
/**
42
42
* Reactive repository base implementation for Mongo.
43
43
*
@@ -66,13 +66,21 @@ public SimpleReactiveMongoRepository(MongoEntityInformation<T, ID> metadata,
66
66
this .mongoOperations = mongoOperations ;
67
67
}
68
68
69
+ /* (non-Javadoc)
70
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findOne(java.io.Serializable)
71
+ */
72
+ @ Override
69
73
public Mono <T > findOne (ID id ) {
70
74
71
75
Assert .notNull (id , "The given id must not be null!" );
72
76
73
77
return mongoOperations .findById (id , entityInformation .getJavaType (), entityInformation .getCollectionName ());
74
78
}
75
79
80
+ /* (non-Javadoc)
81
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findOne(reactor.core.publisher.Mono)
82
+ */
83
+ @ Override
76
84
public Mono <T > findOne (Mono <ID > mono ) {
77
85
78
86
Assert .notNull (mono , "The given id must not be null!" );
@@ -81,6 +89,9 @@ public Mono<T> findOne(Mono<ID> mono) {
81
89
id -> mongoOperations .findById (id , entityInformation .getJavaType (), entityInformation .getCollectionName ()));
82
90
}
83
91
92
+ /* (non-Javadoc)
93
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findOne(org.springframework.data.domain.Example)
94
+ */
84
95
public <S extends T > Mono <S > findOne (Example <S > example ) {
85
96
86
97
Assert .notNull (example , "Sample must not be null!" );
@@ -89,6 +100,10 @@ public <S extends T> Mono<S> findOne(Example<S> example) {
89
100
return mongoOperations .findOne (q , example .getProbeType (), entityInformation .getCollectionName ());
90
101
}
91
102
103
+ /* (non-Javadoc)
104
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#exists(java.io.Serializable)
105
+ */
106
+ @ Override
92
107
public Mono <Boolean > exists (ID id ) {
93
108
94
109
Assert .notNull (id , "The given id must not be null!" );
@@ -97,6 +112,10 @@ public Mono<Boolean> exists(ID id) {
97
112
entityInformation .getCollectionName ());
98
113
}
99
114
115
+ /* (non-Javadoc)
116
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#exists(reactor.core.publisher.Mono)
117
+ */
118
+ @ Override
100
119
public Mono <Boolean > exists (Mono <ID > mono ) {
101
120
102
121
Assert .notNull (mono , "The given id must not be null!" );
@@ -106,6 +125,10 @@ public Mono<Boolean> exists(Mono<ID> mono) {
106
125
107
126
}
108
127
128
+ /* (non-Javadoc)
129
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#exists(org.springframework.data.domain.Example)
130
+ */
131
+ @ Override
109
132
public <S extends T > Mono <Boolean > exists (Example <S > example ) {
110
133
111
134
Assert .notNull (example , "Sample must not be null!" );
@@ -114,11 +137,17 @@ public <S extends T> Mono<Boolean> exists(Example<S> example) {
114
137
return mongoOperations .exists (q , example .getProbeType (), entityInformation .getCollectionName ());
115
138
}
116
139
140
+ /* (non-Javadoc)
141
+ * @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll()
142
+ */
117
143
@ Override
118
144
public Flux <T > findAll () {
119
145
return findAll (new Query ());
120
146
}
121
147
148
+ /* (non-Javadoc)
149
+ * @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll(java.lang.Iterable)
150
+ */
122
151
@ Override
123
152
public Flux <T > findAll (Iterable <ID > ids ) {
124
153
@@ -132,6 +161,9 @@ public Flux<T> findAll(Iterable<ID> ids) {
132
161
return findAll (new Query (new Criteria (entityInformation .getIdAttribute ()).in (parameters )));
133
162
}
134
163
164
+ /* (non-Javadoc)
165
+ * @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll(org.reactivestreams.Publisher)
166
+ */
135
167
@ Override
136
168
public Flux <T > findAll (Publisher <ID > idStream ) {
137
169
@@ -140,11 +172,17 @@ public Flux<T> findAll(Publisher<ID> idStream) {
140
172
return Flux .from (idStream ).buffer ().flatMap (this ::findAll );
141
173
}
142
174
175
+ /* (non-Javadoc)
176
+ * @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll(org.springframework.data.domain.Sort)
177
+ */
143
178
@ Override
144
179
public Flux <T > findAll (Sort sort ) {
145
180
return findAll (new Query ().with (sort ));
146
181
}
147
182
183
+ /* (non-Javadoc)
184
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort)
185
+ */
148
186
@ Override
149
187
public <S extends T > Flux <S > findAll (Example <S > example , Sort sort ) {
150
188
@@ -159,15 +197,26 @@ public <S extends T> Flux<S> findAll(Example<S> example, Sort sort) {
159
197
return mongoOperations .find (q , example .getProbeType (), entityInformation .getCollectionName ());
160
198
}
161
199
200
+ /* (non-Javadoc)
201
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findAll(org.springframework.data.domain.Example)
202
+ */
162
203
@ Override
163
204
public <S extends T > Flux <S > findAll (Example <S > example ) {
164
205
return findAll (example , null );
165
206
}
166
207
208
+ /* (non-Javadoc)
209
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#count()
210
+ */
211
+ @ Override
167
212
public Mono <Long > count () {
168
213
return mongoOperations .count (new Query (), entityInformation .getCollectionName ());
169
214
}
170
215
216
+ /* (non-Javadoc)
217
+ * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#count(org.springframework.data.domain.Example)
218
+ */
219
+ @ Override
171
220
public <S extends T > Mono <Long > count (Example <S > example ) {
172
221
173
222
Assert .notNull (example , "Sample must not be null!" );
@@ -176,6 +225,9 @@ public <S extends T> Mono<Long> count(Example<S> example) {
176
225
return mongoOperations .count (q , example .getProbeType (), entityInformation .getCollectionName ());
177
226
}
178
227
228
+ /* (non-Javadoc)
229
+ * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Object)
230
+ */
179
231
@ Override
180
232
public <S extends T > Mono <S > insert (S entity ) {
181
233
@@ -184,6 +236,9 @@ public <S extends T> Mono<S> insert(S entity) {
184
236
return mongoOperations .insert (entity , entityInformation .getCollectionName ());
185
237
}
186
238
239
+ /* (non-Javadoc)
240
+ * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Iterable)
241
+ */
187
242
@ Override
188
243
public <S extends T > Flux <S > insert (Iterable <S > entities ) {
189
244
@@ -198,6 +253,9 @@ public <S extends T> Flux<S> insert(Iterable<S> entities) {
198
253
return Flux .from (mongoOperations .insertAll (list ));
199
254
}
200
255
256
+ /* (non-Javadoc)
257
+ * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(org.reactivestreams.Publisher)
258
+ */
201
259
@ Override
202
260
public <S extends T > Flux <S > insert (Publisher <S > entities ) {
203
261
@@ -206,6 +264,10 @@ public <S extends T> Flux<S> insert(Publisher<S> entities) {
206
264
return Flux .from (entities ).flatMap (entity -> mongoOperations .insert (entity , entityInformation .getCollectionName ()));
207
265
}
208
266
267
+ /* (non-Javadoc)
268
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#save(S)
269
+ */
270
+ @ Override
209
271
public <S extends T > Mono <S > save (S entity ) {
210
272
211
273
Assert .notNull (entity , "Entity must not be null!" );
@@ -217,6 +279,10 @@ public <S extends T> Mono<S> save(S entity) {
217
279
return mongoOperations .save (entity , entityInformation .getCollectionName ());
218
280
}
219
281
282
+ /* (non-Javadoc)
283
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#save(java.lang.Iterable)
284
+ */
285
+ @ Override
220
286
public <S extends T > Flux <S > save (Iterable <S > entities ) {
221
287
222
288
Assert .notNull (entities , "The given Iterable of entities must not be null!" );
@@ -242,6 +308,9 @@ public <S extends T> Flux<S> save(Iterable<S> entities) {
242
308
return Flux .merge (monos );
243
309
}
244
310
311
+ /* (non-Javadoc)
312
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#save(org.reactivestreams.Publisher)
313
+ */
245
314
@ Override
246
315
public <S extends T > Flux <S > save (Publisher <S > entityStream ) {
247
316
@@ -258,6 +327,10 @@ public <S extends T> Flux<S> save(Publisher<S> entityStream) {
258
327
}
259
328
260
329
// TODO: should this one really be void?
330
+ /* (non-Javadoc)
331
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(java.io.Serializable)
332
+ */
333
+ @ Override
261
334
public Mono <Void > delete (ID id ) {
262
335
263
336
Assert .notNull (id , "The given id must not be null!" );
@@ -268,6 +341,10 @@ public Mono<Void> delete(ID id) {
268
341
}
269
342
270
343
// TODO: should this one really be void?
344
+ /* (non-Javadoc)
345
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(java.lang.Object)
346
+ */
347
+ @ Override
271
348
public Mono <Void > delete (T entity ) {
272
349
273
350
Assert .notNull (entity , "The given entity must not be null!" );
@@ -276,6 +353,10 @@ public Mono<Void> delete(T entity) {
276
353
}
277
354
278
355
// TODO: should this one really be void?
356
+ /* (non-Javadoc)
357
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(java.lang.Iterable)
358
+ */
359
+ @ Override
279
360
public Mono <Void > delete (Iterable <? extends T > entities ) {
280
361
281
362
Assert .notNull (entities , "The given Iterable of entities must not be null!" );
@@ -284,6 +365,9 @@ public Mono<Void> delete(Iterable<? extends T> entities) {
284
365
}
285
366
286
367
// TODO: should this one really be void?
368
+ /* (non-Javadoc)
369
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(org.reactivestreams.Publisher)
370
+ */
287
371
@ Override
288
372
public Mono <Void > delete (Publisher <? extends T > entityStream ) {
289
373
@@ -293,6 +377,9 @@ public Mono<Void> delete(Publisher<? extends T> entityStream) {
293
377
}
294
378
295
379
// TODO: should this one really be void?
380
+ /* (non-Javadoc)
381
+ * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll()
382
+ */
296
383
public Mono <Void > deleteAll () {
297
384
return mongoOperations .remove (new Query (), entityInformation .getCollectionName ())
298
385
.then (deleteResult -> Mono .empty ());
0 commit comments