Skip to content

Commit 6ad5f62

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 1585cc4 commit 6ad5f62

32 files changed

+246
-195
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
@@ -211,7 +211,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory) {
211211
*/
212212
public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
213213

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

216216
this.mongoDbFactory = mongoDbFactory;
217217
this.exceptionTranslator = mongoDbFactory.getExceptionTranslator();
@@ -423,7 +423,7 @@ public void executeQuery(Query query, String collectionName, DocumentCallbackHan
423423
protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler dch,
424424
CursorPreparer preparer) {
425425

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

428428
DBObject queryObject = queryMapper.getMappedObject(query.getQueryObject(), null);
429429
DBObject sortObject = query.getSortObject();
@@ -439,7 +439,7 @@ protected void executeQuery(Query query, String collectionName, DocumentCallback
439439

440440
public <T> T execute(DbCallback<T> action) {
441441

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

444444
try {
445445
DB db = this.getDb();
@@ -455,7 +455,7 @@ public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
455455

456456
public <T> T execute(String collectionName, CollectionCallback<T> callback) {
457457

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

460460
try {
461461
DBCollection collection = getAndPrepareCollection(getDb(), collectionName);
@@ -733,7 +733,8 @@ public <T> T findAndRemove(Query query, Class<T> entityClass, String collectionN
733733
}
734734

735735
public long count(Query query, Class<?> entityClass) {
736-
Assert.notNull(entityClass);
736+
737+
Assert.notNull(entityClass, "Entity class must not be null!");
737738
return count(query, entityClass, determineCollectionName(entityClass));
738739
}
739740

@@ -747,7 +748,8 @@ public long count(final Query query, String collectionName) {
747748
*/
748749
public long count(Query query, Class<?> entityClass, String collectionName) {
749750

750-
Assert.hasText(collectionName);
751+
Assert.hasText(collectionName, "Collection name must not be null or empty!");
752+
751753
final DBObject dbObject = query == null ? null
752754
: queryMapper.getMappedObject(query.getQueryObject(),
753755
entityClass == null ? null : mappingContext.getPersistentEntity(entityClass));
@@ -918,7 +920,7 @@ protected <T> void doInsertAll(Collection<? extends T> listToSave, MongoWriter<T
918920

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

921-
Assert.notNull(writer);
923+
Assert.notNull(writer, "MongoWriter must not be null!");
922924

923925
List<DBObject> dbObjectList = new ArrayList<DBObject>();
924926
for (T o : batchToSave) {
@@ -947,14 +949,14 @@ protected <T> void doInsertBatch(String collectionName, Collection<? extends T>
947949

948950
public void save(Object objectToSave) {
949951

950-
Assert.notNull(objectToSave);
952+
Assert.notNull(objectToSave, "Object to save must not be null!");
951953
save(objectToSave, determineEntityCollectionName(objectToSave));
952954
}
953955

954956
public void save(Object objectToSave, String collectionName) {
955957

956-
Assert.notNull(objectToSave);
957-
Assert.hasText(collectionName);
958+
Assert.notNull(objectToSave, "Object to save must not be null!");
959+
Assert.hasText(collectionName, "Collection name must not be null or empty!");
958960

959961
MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass());
960962

@@ -1200,7 +1202,7 @@ public WriteResult remove(Object object) {
12001202

12011203
public WriteResult remove(Object object, String collection) {
12021204

1203-
Assert.hasText(collection);
1205+
Assert.hasText(collection, "Collection name must not be null or empty!");
12041206

12051207
if (object == null) {
12061208
return null;
@@ -2281,8 +2283,9 @@ private class ReadDbObjectCallback<T> implements DbObjectCallback<T> {
22812283

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

2284-
Assert.notNull(reader);
2285-
Assert.notNull(type);
2286+
Assert.notNull(reader, "EntityReader must not be null!");
2287+
Assert.notNull(type, "Entity type must not be null!");
2288+
22862289
this.reader = reader;
22872290
this.type = type;
22882291
this.collectionName = collectionName;
@@ -2404,7 +2407,9 @@ static class GeoNearResultDbObjectCallback<T> implements DbObjectCallback<GeoRes
24042407
* @param delegate must not be {@literal null}.
24052408
*/
24062409
public GeoNearResultDbObjectCallback(DbObjectCallback<T> delegate, Metric metric) {
2407-
Assert.notNull(delegate);
2410+
2411+
Assert.notNull(delegate, "DocumentCallback must not be null!");
2412+
24082413
this.delegate = delegate;
24092414
this.metric = metric;
24102415
}

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,
@@ -310,7 +310,7 @@ public void doWithAssociation(Association<MongoPersistentProperty> association)
310310
return result;
311311
}
312312

313-
/*
313+
/*
314314
* (non-Javadoc)
315315
* @see org.springframework.data.mongodb.core.convert.MongoWriter#toDBRef(java.lang.Object, org.springframework.data.mongodb.core.mapping.MongoPersistentProperty)
316316
*/
@@ -478,7 +478,7 @@ protected void writePropertyInternal(Object obj, DBObject dbo, MongoPersistentPr
478478
DBRef dbRefObj = null;
479479

480480
/*
481-
* If we already have a LazyLoadingProxy, we use it's cached DBRef value instead of
481+
* If we already have a LazyLoadingProxy, we use it's cached DBRef value instead of
482482
* unnecessarily initializing it only to convert it to a DBRef a few instructions later.
483483
*/
484484
if (obj instanceof LazyLoadingProxy) {
@@ -825,7 +825,7 @@ private Object getPotentiallyConvertedSimpleRead(Object value, Class<?> target)
825825

826826
protected DBRef createDBRef(Object target, MongoPersistentProperty property) {
827827

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

830830
if (target instanceof DBRef) {
831831
return (DBRef) target;
@@ -1053,7 +1053,7 @@ public BasicDBList maybeConvertList(Iterable<?> source, TypeInformation<?> typeI
10531053

10541054
/**
10551055
* Removes the type information from the entire conversion result.
1056-
*
1056+
*
10571057
* @param object
10581058
* @param recursively whether to apply the removal recursively
10591059
* @return
@@ -1114,22 +1114,22 @@ private class MongoDbPropertyValueProvider implements PropertyValueProvider<Mong
11141114
/**
11151115
* Creates a new {@link MongoDbPropertyValueProvider} for the given source, {@link SpELExpressionEvaluator} and
11161116
* {@link ObjectPath}.
1117-
*
1117+
*
11181118
* @param source must not be {@literal null}.
11191119
* @param evaluator must not be {@literal null}.
11201120
* @param path can be {@literal null}.
11211121
*/
11221122
public MongoDbPropertyValueProvider(DBObject source, SpELExpressionEvaluator evaluator, ObjectPath path) {
11231123

1124-
Assert.notNull(source);
1125-
Assert.notNull(evaluator);
1124+
Assert.notNull(source, "DBObject must not be null!");
1125+
Assert.notNull(evaluator, "SpELExpressionEvaluator must not be null!");
11261126

11271127
this.source = new DBObjectAccessor(source);
11281128
this.evaluator = evaluator;
11291129
this.path = path;
11301130
}
11311131

1132-
/*
1132+
/*
11331133
* (non-Javadoc)
11341134
* @see org.springframework.data.convert.PropertyValueProvider#getPropertyValue(org.springframework.data.mapping.PersistentProperty)
11351135
*/
@@ -1172,7 +1172,7 @@ public ConverterAwareSpELExpressionParameterValueProvider(SpELExpressionEvaluato
11721172
this.path = path;
11731173
}
11741174

1175-
/*
1175+
/*
11761176
* (non-Javadoc)
11771177
* @see org.springframework.data.mapping.model.SpELExpressionParameterValueProvider#potentiallyConvertSpelValue(java.lang.Object, org.springframework.data.mapping.PreferredConstructor.Parameter)
11781178
*/

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)