Skip to content

Commit 1f06954

Browse files
committed
Polishing.
Add missing Override annotations to template API methods. See #3984
1 parent 7bcf032 commit 1f06954

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

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

+28
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public void setReadPreference(@Nullable ReadPreference readPreference) {
308308
this.readPreference = readPreference;
309309
}
310310

311+
@Override
311312
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
312313

313314
prepareIndexCreator(applicationContext);
@@ -411,6 +412,7 @@ private void prepareIndexCreator(ApplicationContext context) {
411412
*
412413
* @return
413414
*/
415+
@Override
414416
public MongoConverter getConverter() {
415417
return this.mongoConverter;
416418
}
@@ -521,6 +523,7 @@ protected void executeQuery(Query query, String collectionName, DocumentCallback
521523
preparer != null ? preparer : CursorPreparer.NO_OP_PREPARER, documentCallbackHandler, collectionName);
522524
}
523525

526+
@Override
524527
public <T> T execute(DbCallback<T> action) {
525528

526529
Assert.notNull(action, "DbCallback must not be null!");
@@ -533,12 +536,14 @@ public <T> T execute(DbCallback<T> action) {
533536
}
534537
}
535538

539+
@Override
536540
public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
537541

538542
Assert.notNull(entityClass, "EntityClass must not be null!");
539543
return execute(getCollectionName(entityClass), callback);
540544
}
541545

546+
@Override
542547
public <T> T execute(String collectionName, CollectionCallback<T> callback) {
543548

544549
Assert.notNull(collectionName, "CollectionName must not be null!");
@@ -579,10 +584,12 @@ public void setSessionSynchronization(SessionSynchronization sessionSynchronizat
579584
this.sessionSynchronization = sessionSynchronization;
580585
}
581586

587+
@Override
582588
public <T> MongoCollection<Document> createCollection(Class<T> entityClass) {
583589
return createCollection(entityClass, operations.forType(entityClass).getCollectionOptions());
584590
}
585591

592+
@Override
586593
public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
587594
@Nullable CollectionOptions collectionOptions) {
588595

@@ -597,20 +604,23 @@ public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
597604
return doCreateCollection(getCollectionName(entityClass), convertToDocument(options, entityClass));
598605
}
599606

607+
@Override
600608
public MongoCollection<Document> createCollection(String collectionName) {
601609

602610
Assert.notNull(collectionName, "CollectionName must not be null!");
603611

604612
return doCreateCollection(collectionName, new Document());
605613
}
606614

615+
@Override
607616
public MongoCollection<Document> createCollection(String collectionName,
608617
@Nullable CollectionOptions collectionOptions) {
609618

610619
Assert.notNull(collectionName, "CollectionName must not be null!");
611620
return doCreateCollection(collectionName, convertToDocument(collectionOptions, Object.class));
612621
}
613622

623+
@Override
614624
@SuppressWarnings("ConstantConditions")
615625
public MongoCollection<Document> getCollection(String collectionName) {
616626

@@ -619,10 +629,12 @@ public MongoCollection<Document> getCollection(String collectionName) {
619629
return execute(db -> db.getCollection(collectionName, Document.class));
620630
}
621631

632+
@Override
622633
public <T> boolean collectionExists(Class<T> entityClass) {
623634
return collectionExists(getCollectionName(entityClass));
624635
}
625636

637+
@Override
626638
@SuppressWarnings("ConstantConditions")
627639
public boolean collectionExists(String collectionName) {
628640

@@ -639,10 +651,12 @@ public boolean collectionExists(String collectionName) {
639651
});
640652
}
641653

654+
@Override
642655
public <T> void dropCollection(Class<T> entityClass) {
643656
dropCollection(getCollectionName(entityClass));
644657
}
645658

659+
@Override
646660
public void dropCollection(String collectionName) {
647661

648662
Assert.notNull(collectionName, "CollectionName must not be null!");
@@ -662,22 +676,27 @@ public IndexOperations indexOps(String collectionName) {
662676
return indexOps(collectionName, null);
663677
}
664678

679+
@Override
665680
public IndexOperations indexOps(String collectionName, @Nullable Class<?> type) {
666681
return new DefaultIndexOperations(this, collectionName, type);
667682
}
668683

684+
@Override
669685
public IndexOperations indexOps(Class<?> entityClass) {
670686
return indexOps(getCollectionName(entityClass), entityClass);
671687
}
672688

689+
@Override
673690
public BulkOperations bulkOps(BulkMode bulkMode, String collectionName) {
674691
return bulkOps(bulkMode, null, collectionName);
675692
}
676693

694+
@Override
677695
public BulkOperations bulkOps(BulkMode bulkMode, Class<?> entityClass) {
678696
return bulkOps(bulkMode, entityClass, getCollectionName(entityClass));
679697
}
680698

699+
@Override
681700
public BulkOperations bulkOps(BulkMode mode, @Nullable Class<?> entityType, String collectionName) {
682701

683702
Assert.notNull(mode, "BulkMode must not be null!");
@@ -1017,6 +1036,7 @@ public long count(Query query, String collectionName) {
10171036
* (non-Javadoc)
10181037
* @see org.springframework.data.mongodb.core.MongoOperations#count(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String)
10191038
*/
1039+
@Override
10201040
public long count(Query query, @Nullable Class<?> entityClass, String collectionName) {
10211041

10221042
Assert.notNull(query, "Query must not be null!");
@@ -2127,6 +2147,7 @@ protected String replaceWithResourceIfNecessary(String function) {
21272147
return func;
21282148
}
21292149

2150+
@Override
21302151
@SuppressWarnings("ConstantConditions")
21312152
public Set<String> getCollectionNames() {
21322153
return execute(db -> {
@@ -2782,6 +2803,7 @@ public FindCallback(Document query, Document fields, @Nullable com.mongodb.clien
27822803
this.collation = collation;
27832804
}
27842805

2806+
@Override
27852807
public FindIterable<Document> doInCollection(MongoCollection<Document> collection)
27862808
throws MongoException, DataAccessException {
27872809

@@ -2841,6 +2863,7 @@ private static class FindAndRemoveCallback implements CollectionCallback<Documen
28412863
this.collation = Optional.ofNullable(collation);
28422864
}
28432865

2866+
@Override
28442867
public Document doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
28452868

28462869
FindOneAndDeleteOptions opts = new FindOneAndDeleteOptions().sort(sort).projection(fields);
@@ -2870,6 +2893,7 @@ private static class FindAndModifyCallback implements CollectionCallback<Documen
28702893
this.options = options;
28712894
}
28722895

2896+
@Override
28732897
public Document doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
28742898

28752899
FindOneAndUpdateOptions opts = new FindOneAndUpdateOptions();
@@ -2978,6 +3002,7 @@ private class ReadDocumentCallback<T> implements DocumentCallback<T> {
29783002
this.collectionName = collectionName;
29793003
}
29803004

3005+
@Override
29813006
public T doWith(Document document) {
29823007

29833008
maybeEmitEvent(new AfterLoadEvent<>(document, type, collectionName));
@@ -3015,6 +3040,7 @@ private class ProjectingReadCallback<S, T> implements DocumentCallback<T> {
30153040
this.collectionName = collectionName;
30163041
}
30173042

3043+
@Override
30183044
@SuppressWarnings("unchecked")
30193045
public T doWith(Document document) {
30203046

@@ -3046,6 +3072,7 @@ class QueryCursorPreparer implements CursorPreparer {
30463072
this.type = type;
30473073
}
30483074

3075+
@Override
30493076
public FindIterable<Document> prepare(FindIterable<Document> iterable) {
30503077

30513078
FindIterable<Document> cursorToUse = iterable;
@@ -3163,6 +3190,7 @@ static class GeoNearResultDocumentCallback<T> implements DocumentCallback<GeoRes
31633190
this.metric = metric;
31643191
}
31653192

3193+
@Override
31663194
public GeoResult<T> doWith(Document object) {
31673195

31683196
double distance = Double.NaN;

0 commit comments

Comments
 (0)