Skip to content

Commit 18e00a9

Browse files
committed
DATAMONGO-1602 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message. Related ticket: SPR-15196.
1 parent b79474c commit 18e00a9

32 files changed

+213
-163
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2014 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -361,7 +361,9 @@ private static class NegatingFilter implements TypeFilter {
361361
* @param filters
362362
*/
363363
public NegatingFilter(TypeFilter... filters) {
364-
Assert.notNull(filters);
364+
365+
Assert.notNull(filters, "TypeFilters must not be null");
366+
365367
this.delegates = new HashSet<TypeFilter>(Arrays.asList(filters));
366368
}
367369

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2013 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,18 +27,20 @@
2727
* Mongo server administration exposed via JMX annotations
2828
*
2929
* @author Mark Pollack
30-
* @author Thomas Darimont
30+
* @author Thomas Darimont
31+
* @author Mark Paluch
3132
*/
3233
@ManagedResource(description = "Mongo Admin Operations")
3334
public class MongoAdmin implements MongoAdminOperations {
3435

3536
private final Mongo mongo;
3637
private String username;
3738
private String password;
38-
private String authenticationDatabaseName;
39+
private String authenticationDatabaseName;
3940

4041
public MongoAdmin(Mongo mongo) {
41-
Assert.notNull(mongo);
42+
43+
Assert.notNull(mongo, "Mongo must not be null!");
4244
this.mongo = mongo;
4345
}
4446

@@ -84,16 +86,16 @@ public void setPassword(String password) {
8486
this.password = password;
8587
}
8688

87-
/**
88-
* Sets the authenticationDatabaseName to use to authenticate with the Mongo database.
89-
*
90-
* @param authenticationDatabaseName The authenticationDatabaseName to use.
91-
*/
92-
public void setAuthenticationDatabaseName(String authenticationDatabaseName) {
93-
this.authenticationDatabaseName = authenticationDatabaseName;
94-
}
95-
89+
/**
90+
* Sets the authenticationDatabaseName to use to authenticate with the Mongo database.
91+
*
92+
* @param authenticationDatabaseName The authenticationDatabaseName to use.
93+
*/
94+
public void setAuthenticationDatabaseName(String authenticationDatabaseName) {
95+
this.authenticationDatabaseName = authenticationDatabaseName;
96+
}
97+
9698
DB getDB(String databaseName) {
97-
return MongoDbUtils.getDB(mongo, databaseName, new UserCredentials(username, password), authenticationDatabaseName);
99+
return MongoDbUtils.getDB(mongo, databaseName, new UserCredentials(username, password), authenticationDatabaseName);
98100
}
99101
}

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory) {
214214
*/
215215
public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
216216

217-
Assert.notNull(mongoDbFactory);
217+
Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!");
218218

219219
this.mongoDbFactory = mongoDbFactory;
220220
this.exceptionTranslator = mongoDbFactory.getExceptionTranslator();
@@ -439,7 +439,7 @@ public void executeQuery(Query query, String collectionName, DocumentCallbackHan
439439
protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler dch,
440440
CursorPreparer preparer) {
441441

442-
Assert.notNull(query);
442+
Assert.notNull(query, "Query must not be null!");
443443

444444
DBObject queryObject = queryMapper.getMappedObject(query.getQueryObject(), null);
445445
DBObject sortObject = query.getSortObject();
@@ -455,7 +455,7 @@ protected void executeQuery(Query query, String collectionName, DocumentCallback
455455

456456
public <T> T execute(DbCallback<T> action) {
457457

458-
Assert.notNull(action);
458+
Assert.notNull(action, "DbCallbackmust not be null!");
459459

460460
try {
461461
DB db = this.getDb();
@@ -471,7 +471,7 @@ public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
471471

472472
public <T> T execute(String collectionName, CollectionCallback<T> callback) {
473473

474-
Assert.notNull(callback);
474+
Assert.notNull(callback, "CollectionCallback must not be null!");
475475

476476
try {
477477
DBCollection collection = getAndPrepareCollection(getDb(), collectionName);
@@ -749,7 +749,8 @@ public <T> T findAndRemove(Query query, Class<T> entityClass, String collectionN
749749
}
750750

751751
public long count(Query query, Class<?> entityClass) {
752-
Assert.notNull(entityClass);
752+
753+
Assert.notNull(entityClass, "Entity class must not be null!");
753754
return count(query, entityClass, determineCollectionName(entityClass));
754755
}
755756

@@ -763,7 +764,8 @@ public long count(final Query query, String collectionName) {
763764
*/
764765
public long count(Query query, Class<?> entityClass, String collectionName) {
765766

766-
Assert.hasText(collectionName);
767+
Assert.hasText(collectionName, "Collection name must not be null or empty!");
768+
767769
final DBObject dbObject = query == null ? null
768770
: queryMapper.getMappedObject(query.getQueryObject(),
769771
entityClass == null ? null : mappingContext.getPersistentEntity(entityClass));
@@ -934,7 +936,7 @@ protected <T> void doInsertAll(Collection<? extends T> listToSave, MongoWriter<T
934936

935937
protected <T> void doInsertBatch(String collectionName, Collection<? extends T> batchToSave, MongoWriter<T> writer) {
936938

937-
Assert.notNull(writer);
939+
Assert.notNull(writer, "MongoWriter must not be null!");
938940

939941
List<DBObject> dbObjectList = new ArrayList<DBObject>();
940942
for (T o : batchToSave) {
@@ -963,14 +965,14 @@ protected <T> void doInsertBatch(String collectionName, Collection<? extends T>
963965

964966
public void save(Object objectToSave) {
965967

966-
Assert.notNull(objectToSave);
968+
Assert.notNull(objectToSave, "Object to save must not be null!");
967969
save(objectToSave, determineEntityCollectionName(objectToSave));
968970
}
969971

970972
public void save(Object objectToSave, String collectionName) {
971973

972-
Assert.notNull(objectToSave);
973-
Assert.hasText(collectionName);
974+
Assert.notNull(objectToSave, "Object to save must not be null!");
975+
Assert.hasText(collectionName, "Collection name must not be null or empty!");
974976

975977
MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass());
976978

@@ -1216,7 +1218,7 @@ public WriteResult remove(Object object) {
12161218

12171219
public WriteResult remove(Object object, String collection) {
12181220

1219-
Assert.hasText(collection);
1221+
Assert.hasText(collection, "Collection name must not be null or empty!");
12201222

12211223
if (object == null) {
12221224
return null;
@@ -2297,8 +2299,9 @@ private class ReadDbObjectCallback<T> implements DbObjectCallback<T> {
22972299

22982300
public ReadDbObjectCallback(EntityReader<? super T, DBObject> reader, Class<T> type, String collectionName) {
22992301

2300-
Assert.notNull(reader);
2301-
Assert.notNull(type);
2302+
Assert.notNull(reader, "EntityReader must not be null!");
2303+
Assert.notNull(type, "Entity type must not be null!");
2304+
23022305
this.reader = reader;
23032306
this.type = type;
23042307
this.collectionName = collectionName;
@@ -2446,7 +2449,9 @@ static class GeoNearResultDbObjectCallback<T> implements DbObjectCallback<GeoRes
24462449
* @param delegate must not be {@literal null}.
24472450
*/
24482451
public GeoNearResultDbObjectCallback(DbObjectCallback<T> delegate, Metric metric) {
2449-
Assert.notNull(delegate);
2452+
2453+
Assert.notNull(delegate, "DocumentCallback must not be null!");
2454+
24502455
this.delegate = delegate;
24512456
this.metric = metric;
24522457
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
* @author Tobias Trelle
3030
* @author Oliver Gierke
3131
* @author Thomas Darimont
32+
* @author Mark Paluch
3233
* @param <T> The class in which the results are mapped onto.
3334
* @since 1.3
3435
*/
@@ -46,8 +47,8 @@ public class AggregationResults<T> implements Iterable<T> {
4647
*/
4748
public AggregationResults(List<T> mappedResults, DBObject rawResults) {
4849

49-
Assert.notNull(mappedResults);
50-
Assert.notNull(rawResults);
50+
Assert.notNull(mappedResults, "List of mapped results must not be null!");
51+
Assert.notNull(rawResults, "Raw results must not be null!");
5152

5253
this.mappedResults = Collections.unmodifiableList(mappedResults);
5354
this.rawResults = rawResults;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
* Conversion registration information.
2424
*
2525
* @author Oliver Gierke
26+
* @author Mark Paluch
2627
*/
2728
class ConverterRegistration {
2829

@@ -39,7 +40,7 @@ class ConverterRegistration {
3940
*/
4041
public ConverterRegistration(ConvertiblePair convertiblePair, boolean isReading, boolean isWriting) {
4142

42-
Assert.notNull(convertiblePair);
43+
Assert.notNull(convertiblePair, "ConvertiblePair must not be null!");
4344

4445
this.convertiblePair = convertiblePair;
4546
this.reading = isReading;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class CustomConversions {
8989
*/
9090
public CustomConversions(List<?> converters) {
9191

92-
Assert.notNull(converters);
92+
Assert.notNull(converters, "List of converters must not be null!");
9393

9494
this.readingPairs = new LinkedHashSet<ConvertiblePair>();
9595
this.writingPairs = new LinkedHashSet<ConvertiblePair>();
@@ -346,8 +346,8 @@ public Class<?> get() {
346346
private static Class<?> getCustomTarget(Class<?> sourceType, Class<?> requestedTargetType,
347347
Collection<ConvertiblePair> pairs) {
348348

349-
Assert.notNull(sourceType);
350-
Assert.notNull(pairs);
349+
Assert.notNull(sourceType, "Source Class must not be null!");
350+
Assert.notNull(pairs, "Collection of ConvertiblePair must not be null!");
351351

352352
if (requestedTargetType != null && pairs.contains(new ConvertiblePair(sourceType, requestedTargetType))) {
353353
return requestedTargetType;

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2011-2017 by the original author(s).
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -315,7 +315,7 @@ public void doWithAssociation(Association<MongoPersistentProperty> association)
315315
return result;
316316
}
317317

318-
/*
318+
/*
319319
* (non-Javadoc)
320320
* @see org.springframework.data.mongodb.core.convert.MongoWriter#toDBRef(java.lang.Object, org.springframework.data.mongodb.core.mapping.MongoPersistentProperty)
321321
*/
@@ -483,7 +483,7 @@ protected void writePropertyInternal(Object obj, DBObject dbo, MongoPersistentPr
483483
DBRef dbRefObj = null;
484484

485485
/*
486-
* If we already have a LazyLoadingProxy, we use it's cached DBRef value instead of
486+
* If we already have a LazyLoadingProxy, we use it's cached DBRef value instead of
487487
* unnecessarily initializing it only to convert it to a DBRef a few instructions later.
488488
*/
489489
if (obj instanceof LazyLoadingProxy) {
@@ -830,7 +830,7 @@ private Object getPotentiallyConvertedSimpleRead(Object value, Class<?> target)
830830

831831
protected DBRef createDBRef(Object target, MongoPersistentProperty property) {
832832

833-
Assert.notNull(target);
833+
Assert.notNull(target, "Target object must not be null!");
834834

835835
if (target instanceof DBRef) {
836836
return (DBRef) target;
@@ -1070,7 +1070,7 @@ public BasicDBList maybeConvertList(Iterable<?> source, TypeInformation<?> typeI
10701070

10711071
/**
10721072
* Removes the type information from the entire conversion result.
1073-
*
1073+
*
10741074
* @param object
10751075
* @param recursively whether to apply the removal recursively
10761076
* @return
@@ -1131,22 +1131,22 @@ private class MongoDbPropertyValueProvider implements PropertyValueProvider<Mong
11311131
/**
11321132
* Creates a new {@link MongoDbPropertyValueProvider} for the given source, {@link SpELExpressionEvaluator} and
11331133
* {@link ObjectPath}.
1134-
*
1134+
*
11351135
* @param source must not be {@literal null}.
11361136
* @param evaluator must not be {@literal null}.
11371137
* @param path can be {@literal null}.
11381138
*/
11391139
public MongoDbPropertyValueProvider(DBObject source, SpELExpressionEvaluator evaluator, ObjectPath path) {
11401140

1141-
Assert.notNull(source);
1142-
Assert.notNull(evaluator);
1141+
Assert.notNull(source, "DBObject must not be null!");
1142+
Assert.notNull(evaluator, "SpELExpressionEvaluator must not be null!");
11431143

11441144
this.source = new DBObjectAccessor(source);
11451145
this.evaluator = evaluator;
11461146
this.path = path;
11471147
}
11481148

1149-
/*
1149+
/*
11501150
* (non-Javadoc)
11511151
* @see org.springframework.data.convert.PropertyValueProvider#getPropertyValue(org.springframework.data.mapping.PersistentProperty)
11521152
*/
@@ -1189,7 +1189,7 @@ public ConverterAwareSpELExpressionParameterValueProvider(SpELExpressionEvaluato
11891189
this.path = path;
11901190
}
11911191

1192-
/*
1192+
/*
11931193
* (non-Javadoc)
11941194
* @see org.springframework.data.mapping.model.SpELExpressionParameterValueProvider#potentiallyConvertSpelValue(java.lang.Object, org.springframework.data.mapping.PreferredConstructor.Parameter)
11951195
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ private enum MetaMapping {
8282
*/
8383
public QueryMapper(MongoConverter converter) {
8484

85-
Assert.notNull(converter);
85+
Assert.notNull(converter, "MongoConverter must not be null!");
8686

8787
this.conversionService = converter.getConversionService();
8888
this.converter = converter;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
* Represents a geospatial sphere value.
3030
*
3131
* @author Thomas Darimont
32+
* @author Mark Paluch
3233
* @since 1.5
3334
*/
3435
public class Sphere implements Shape {
@@ -46,8 +47,8 @@ public class Sphere implements Shape {
4647
@PersistenceConstructor
4748
public Sphere(Point center, Distance radius) {
4849

49-
Assert.notNull(center);
50-
Assert.notNull(radius);
50+
Assert.notNull(center, "Center point must not be null!");
51+
Assert.notNull(radius, "Radius must not be null!");
5152
Assert.isTrue(radius.getValue() >= 0, "Radius must not be negative!");
5253

5354
this.center = center;

0 commit comments

Comments
 (0)