Skip to content

Commit 391d510

Browse files
committed
Polishing.
Add missing Override annotations to template API methods. See #3984
1 parent fda07d9 commit 391d510

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

+30
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public void setReadPreference(@Nullable ReadPreference readPreference) {
314314
* (non-Javadoc)
315315
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
316316
*/
317+
@Override
317318
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
318319

319320
prepareIndexCreator(applicationContext);
@@ -417,6 +418,7 @@ private void prepareIndexCreator(ApplicationContext context) {
417418
*
418419
* @return
419420
*/
421+
@Override
420422
public MongoConverter getConverter() {
421423
return this.mongoConverter;
422424
}
@@ -557,6 +559,7 @@ protected void executeQuery(Query query, String collectionName, DocumentCallback
557559
* (non-Javadoc)
558560
* @see org.springframework.data.mongodb.core.MongoOperations#execute(org.springframework.data.mongodb.core.DbCallback)
559561
*/
562+
@Override
560563
public <T> T execute(DbCallback<T> action) {
561564

562565
Assert.notNull(action, "DbCallback must not be null!");
@@ -573,6 +576,7 @@ public <T> T execute(DbCallback<T> action) {
573576
* (non-Javadoc)
574577
* @see org.springframework.data.mongodb.core.MongoOperations#execute(java.lang.Class, org.springframework.data.mongodb.core.DbCallback)
575578
*/
579+
@Override
576580
public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
577581

578582
Assert.notNull(entityClass, "EntityClass must not be null!");
@@ -583,6 +587,7 @@ public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
583587
* (non-Javadoc)
584588
* @see org.springframework.data.mongodb.core.MongoOperations#execute(java.lang.String, org.springframework.data.mongodb.core.DbCallback)
585589
*/
590+
@Override
586591
public <T> T execute(String collectionName, CollectionCallback<T> callback) {
587592

588593
Assert.notNull(collectionName, "CollectionName must not be null!");
@@ -635,6 +640,7 @@ public void setSessionSynchronization(SessionSynchronization sessionSynchronizat
635640
* (non-Javadoc)
636641
* @see org.springframework.data.mongodb.core.MongoOperations#createCollection(java.lang.Class)
637642
*/
643+
@Override
638644
public <T> MongoCollection<Document> createCollection(Class<T> entityClass) {
639645
return createCollection(entityClass, operations.forType(entityClass).getCollectionOptions());
640646
}
@@ -643,6 +649,7 @@ public <T> MongoCollection<Document> createCollection(Class<T> entityClass) {
643649
* (non-Javadoc)
644650
* @see org.springframework.data.mongodb.core.MongoOperations#createCollection(java.lang.Class, org.springframework.data.mongodb.core.CollectionOptions)
645651
*/
652+
@Override
646653
public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
647654
@Nullable CollectionOptions collectionOptions) {
648655

@@ -656,6 +663,7 @@ public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
656663
* (non-Javadoc)
657664
* @see org.springframework.data.mongodb.core.MongoOperations#createCollection(java.lang.String)
658665
*/
666+
@Override
659667
public MongoCollection<Document> createCollection(String collectionName) {
660668

661669
Assert.notNull(collectionName, "CollectionName must not be null!");
@@ -667,6 +675,7 @@ public MongoCollection<Document> createCollection(String collectionName) {
667675
* (non-Javadoc)
668676
* @see org.springframework.data.mongodb.core.MongoOperations#createCollection(java.lang.String, org.springframework.data.mongodb.core.CollectionOptions)
669677
*/
678+
@Override
670679
public MongoCollection<Document> createCollection(String collectionName,
671680
@Nullable CollectionOptions collectionOptions) {
672681

@@ -679,6 +688,7 @@ public MongoCollection<Document> createCollection(String collectionName,
679688
* (non-Javadoc)
680689
* @see org.springframework.data.mongodb.core.MongoOperations#getCollection(java.lang.String)
681690
*/
691+
@Override
682692
@SuppressWarnings("ConstantConditions")
683693
public MongoCollection<Document> getCollection(String collectionName) {
684694

@@ -691,6 +701,7 @@ public MongoCollection<Document> getCollection(String collectionName) {
691701
* (non-Javadoc)
692702
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#getCollection(java.lang.Class)
693703
*/
704+
@Override
694705
public <T> boolean collectionExists(Class<T> entityClass) {
695706
return collectionExists(getCollectionName(entityClass));
696707
}
@@ -699,6 +710,7 @@ public <T> boolean collectionExists(Class<T> entityClass) {
699710
* (non-Javadoc)
700711
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#getCollection(java.lang.String)
701712
*/
713+
@Override
702714
@SuppressWarnings("ConstantConditions")
703715
public boolean collectionExists(String collectionName) {
704716

@@ -719,6 +731,7 @@ public boolean collectionExists(String collectionName) {
719731
* (non-Javadoc)
720732
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#dropCollection(java.lang.Class)
721733
*/
734+
@Override
722735
public <T> void dropCollection(Class<T> entityClass) {
723736
dropCollection(getCollectionName(entityClass));
724737
}
@@ -727,6 +740,7 @@ public <T> void dropCollection(Class<T> entityClass) {
727740
* (non-Javadoc)
728741
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#dropCollection(java.lang.String)
729742
*/
743+
@Override
730744
public void dropCollection(String collectionName) {
731745

732746
Assert.notNull(collectionName, "CollectionName must not be null!");
@@ -750,6 +764,7 @@ public IndexOperations indexOps(String collectionName) {
750764
* (non-Javadoc)
751765
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#indexOps(java.lang.String)
752766
*/
767+
@Override
753768
public IndexOperations indexOps(String collectionName, @Nullable Class<?> type) {
754769
return new DefaultIndexOperations(this, collectionName, type);
755770
}
@@ -758,6 +773,7 @@ public IndexOperations indexOps(String collectionName, @Nullable Class<?> type)
758773
* (non-Javadoc)
759774
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#indexOps(java.lang.Class)
760775
*/
776+
@Override
761777
public IndexOperations indexOps(Class<?> entityClass) {
762778
return indexOps(getCollectionName(entityClass), entityClass);
763779
}
@@ -766,6 +782,7 @@ public IndexOperations indexOps(Class<?> entityClass) {
766782
* (non-Javadoc)
767783
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#bulkOps(org.springframework.data.mongodb.core.BulkMode, java.lang.String)
768784
*/
785+
@Override
769786
public BulkOperations bulkOps(BulkMode bulkMode, String collectionName) {
770787
return bulkOps(bulkMode, null, collectionName);
771788
}
@@ -774,6 +791,7 @@ public BulkOperations bulkOps(BulkMode bulkMode, String collectionName) {
774791
* (non-Javadoc)
775792
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#bulkOps(org.springframework.data.mongodb.core.BulkMode, java.lang.Class)
776793
*/
794+
@Override
777795
public BulkOperations bulkOps(BulkMode bulkMode, Class<?> entityClass) {
778796
return bulkOps(bulkMode, entityClass, getCollectionName(entityClass));
779797
}
@@ -782,6 +800,7 @@ public BulkOperations bulkOps(BulkMode bulkMode, Class<?> entityClass) {
782800
* (non-Javadoc)
783801
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#bulkOps(org.springframework.data.mongodb.core.BulkMode, java.lang.Class, java.lang.String)
784802
*/
803+
@Override
785804
public BulkOperations bulkOps(BulkMode mode, @Nullable Class<?> entityType, String collectionName) {
786805

787806
Assert.notNull(mode, "BulkMode must not be null!");
@@ -1145,6 +1164,7 @@ public long count(Query query, String collectionName) {
11451164
* (non-Javadoc)
11461165
* @see org.springframework.data.mongodb.core.MongoOperations#count(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String)
11471166
*/
1167+
@Override
11481168
public long count(Query query, @Nullable Class<?> entityClass, String collectionName) {
11491169

11501170
Assert.notNull(query, "Query must not be null!");
@@ -1984,10 +2004,12 @@ public <T> List<T> mapReduce(Query query, Class<?> domainType, String inputColle
19842004
return mappedResults;
19852005
}
19862006

2007+
@Override
19872008
public <T> GroupByResults<T> group(String inputCollectionName, GroupBy groupBy, Class<T> entityClass) {
19882009
return group(null, inputCollectionName, groupBy, entityClass);
19892010
}
19902011

2012+
@Override
19912013
public <T> GroupByResults<T> group(@Nullable Criteria criteria, String inputCollectionName, GroupBy groupBy,
19922014
Class<T> entityClass) {
19932015

@@ -2396,6 +2418,7 @@ protected String replaceWithResourceIfNecessary(String function) {
23962418
* (non-Javadoc)
23972419
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#getCollectionNames()
23982420
*/
2421+
@Override
23992422
@SuppressWarnings("ConstantConditions")
24002423
public Set<String> getCollectionNames() {
24012424
return execute(db -> {
@@ -3089,6 +3112,7 @@ public FindCallback(Document query, Document fields, @Nullable com.mongodb.clien
30893112
this.collation = collation;
30903113
}
30913114

3115+
@Override
30923116
public FindIterable<Document> doInCollection(MongoCollection<Document> collection)
30933117
throws MongoException, DataAccessException {
30943118

@@ -3148,6 +3172,7 @@ private static class FindAndRemoveCallback implements CollectionCallback<Documen
31483172
this.collation = Optional.ofNullable(collation);
31493173
}
31503174

3175+
@Override
31513176
public Document doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
31523177

31533178
FindOneAndDeleteOptions opts = new FindOneAndDeleteOptions().sort(sort).projection(fields);
@@ -3177,6 +3202,7 @@ private static class FindAndModifyCallback implements CollectionCallback<Documen
31773202
this.options = options;
31783203
}
31793204

3205+
@Override
31803206
public Document doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
31813207

31823208
FindOneAndUpdateOptions opts = new FindOneAndUpdateOptions();
@@ -3289,6 +3315,7 @@ private class ReadDocumentCallback<T> implements DocumentCallback<T> {
32893315
this.collectionName = collectionName;
32903316
}
32913317

3318+
@Override
32923319
public T doWith(Document document) {
32933320

32943321
maybeEmitEvent(new AfterLoadEvent<>(document, type, collectionName));
@@ -3330,6 +3357,7 @@ private class ProjectingReadCallback<S, T> implements DocumentCallback<T> {
33303357
* (non-Javadoc)
33313358
* @see org.springframework.data.mongodb.core.MongoTemplate.DocumentCallback#doWith(org.bson.Document)
33323359
*/
3360+
@Override
33333361
@SuppressWarnings("unchecked")
33343362
public T doWith(Document document) {
33353363

@@ -3365,6 +3393,7 @@ class QueryCursorPreparer implements CursorPreparer {
33653393
* (non-Javadoc)
33663394
* @see org.springframework.data.mongodb.core.CursorPreparer#prepare(com.mongodb.DBCursor)
33673395
*/
3396+
@Override
33683397
public FindIterable<Document> prepare(FindIterable<Document> iterable) {
33693398

33703399
FindIterable<Document> cursorToUse = iterable;
@@ -3483,6 +3512,7 @@ static class GeoNearResultDocumentCallback<T> implements DocumentCallback<GeoRes
34833512
this.metric = metric;
34843513
}
34853514

3515+
@Override
34863516
public GeoResult<T> doWith(Document object) {
34873517

34883518
double distance = Double.NaN;

0 commit comments

Comments
 (0)