Skip to content

Commit 171f906

Browse files
mp911dechristophstrobl
authored andcommitted
DATAMONGO-1619 - Polishing.
Add override annotations. Add override Javadocs.
1 parent 8ccc46f commit 171f906

File tree

1 file changed

+45
-24
lines changed

1 file changed

+45
-24
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ public Mono<T> findById(Mono<ID> mono) {
7676
id -> mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName()));
7777
}
7878

79+
/*
80+
* (non-Javadoc)
81+
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findOne(org.springframework.data.domain.Example)
82+
*/
83+
@Override
84+
public <S extends T> Mono<S> findOne(Example<S> example) {
85+
86+
Assert.notNull(example, "Sample must not be null!");
87+
88+
Query q = new Query(new Criteria().alike(example));
89+
return mongoOperations.findOne(q, example.getProbeType(), entityInformation.getCollectionName());
90+
}
91+
7992
/*
8093
* (non-Javadoc)
8194
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#existsById(java.lang.Object)
@@ -103,6 +116,23 @@ public Mono<Boolean> existsById(Mono<ID> mono) {
103116

104117
}
105118

119+
/*
120+
* (non-Javadoc)
121+
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#exists(org.springframework.data.domain.Example)
122+
*/
123+
@Override
124+
public <S extends T> Mono<Boolean> exists(Example<S> example) {
125+
126+
Assert.notNull(example, "Sample must not be null!");
127+
128+
Query q = new Query(new Criteria().alike(example));
129+
return mongoOperations.exists(q, example.getProbeType(), entityInformation.getCollectionName());
130+
}
131+
132+
/*
133+
* (non-Javadoc)
134+
* @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll()
135+
*/
106136
@Override
107137
public Flux<T> findAll() {
108138
return findAll(new Query());
@@ -170,10 +200,24 @@ public <S extends T> Flux<S> findAll(Example<S> example) {
170200
* (non-Javadoc)
171201
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#count()
172202
*/
203+
@Override
173204
public Mono<Long> count() {
174205
return mongoOperations.count(new Query(), entityInformation.getCollectionName());
175206
}
176207

208+
/*
209+
* (non-Javadoc)
210+
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#count(org.springframework.data.domain.Example)
211+
*/
212+
@Override
213+
public <S extends T> Mono<Long> count(Example<S> example) {
214+
215+
Assert.notNull(example, "Sample must not be null!");
216+
217+
Query q = new Query(new Criteria().alike(example));
218+
return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
219+
}
220+
177221
/*
178222
* (non-Javadoc)
179223
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Object)
@@ -315,34 +359,11 @@ public Mono<Void> deleteAll(Publisher<? extends T> entityStream) {
315359
* (non-Javadoc)
316360
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll()
317361
*/
362+
@Override
318363
public Mono<Void> deleteAll() {
319364
return mongoOperations.remove(new Query(), entityInformation.getCollectionName()).then(Mono.empty());
320365
}
321366

322-
public <S extends T> Mono<Boolean> exists(Example<S> example) {
323-
324-
Assert.notNull(example, "Sample must not be null!");
325-
326-
Query q = new Query(new Criteria().alike(example));
327-
return mongoOperations.exists(q, example.getProbeType(), entityInformation.getCollectionName());
328-
}
329-
330-
public <S extends T> Mono<S> findOne(Example<S> example) {
331-
332-
Assert.notNull(example, "Sample must not be null!");
333-
334-
Query q = new Query(new Criteria().alike(example));
335-
return mongoOperations.findOne(q, example.getProbeType(), entityInformation.getCollectionName());
336-
}
337-
338-
public <S extends T> Mono<Long> count(Example<S> example) {
339-
340-
Assert.notNull(example, "Sample must not be null!");
341-
342-
Query q = new Query(new Criteria().alike(example));
343-
return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
344-
}
345-
346367
private Query getIdQuery(Object id) {
347368
return new Query(getIdCriteria(id));
348369
}

0 commit comments

Comments
 (0)