Browse Source

Remove punctuation in Exception messages.

Closes #4079.
pull/4093/head
John Blum 4 years ago
parent
commit
f15fd2a418
  1. 2
      spring-data-mongodb-benchmarks/src/main/java/org/springframework/data/mongodb/microbenchmark/AbstractMicrobenchmark.java
  2. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/CodecRegistryProvider.java
  3. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDatabaseUtils.java
  4. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoResourceHolder.java
  5. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoTransactionManager.java
  6. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/ReactiveMongoDatabaseUtils.java
  7. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/ReactiveMongoTransactionManager.java
  8. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/SessionAwareMethodInterceptor.java
  9. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java
  10. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoAuditingRegistrar.java
  11. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoCredentialPropertyEditor.java
  12. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoDbFactoryParser.java
  13. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ReactiveMongoAuditingRegistrar.java
  14. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditor.java
  15. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ChangeStreamOptions.java
  16. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java
  17. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CountQuery.java
  18. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CursorPreparer.java
  19. 40
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultBulkOperations.java
  20. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
  21. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java
  22. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultScriptOperations.java
  23. 20
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/EntityOperations.java
  24. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableAggregationOperationSupport.java
  25. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableFindOperationSupport.java
  26. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableInsertOperationSupport.java
  27. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableMapReduceOperationSupport.java
  28. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableRemoveOperationSupport.java
  29. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableUpdateOperationSupport.java
  30. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/FindAndModifyOptions.java
  31. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/FindAndReplaceOptions.java
  32. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/FindPublisherPreparer.java
  33. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/GeoCommandStatistics.java
  34. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MappingMongoJsonSchemaCreator.java
  35. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAction.java
  36. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java
  37. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientFactoryBean.java
  38. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDataIntegrityViolationException.java
  39. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDatabaseFactorySupport.java
  40. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoJsonSchemaCreator.java
  41. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
  42. 222
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
  43. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveAggregationOperationSupport.java
  44. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveChangeStreamOperationSupport.java
  45. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveFindOperationSupport.java
  46. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveInsertOperationSupport.java
  47. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMapReduceOperationSupport.java
  48. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoClientFactoryBean.java
  49. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoContext.java
  50. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java
  51. 138
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java
  52. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveRemoveOperationSupport.java
  53. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveUpdateOperationSupport.java
  54. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleReactiveMongoDatabaseFactory.java
  55. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AbstractAggregationExpression.java
  56. 58
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AccumulatorOperators.java
  57. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java
  58. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationExpressionTransformer.java
  59. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOperationContext.java
  60. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOptions.java
  61. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationPipeline.java
  62. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationResults.java
  63. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationSpELExpression.java
  64. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationUpdate.java
  65. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationUtils.java
  66. 196
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java
  67. 118
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArrayOperators.java
  68. 30
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BooleanOperators.java
  69. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperation.java
  70. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketOperation.java
  71. 30
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketOperationSupport.java
  72. 74
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ComparisonOperators.java
  73. 64
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperators.java
  74. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ConvertOperators.java
  75. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/CountOperation.java
  76. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/DataTypeOperators.java
  77. 158
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/DateOperators.java
  78. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/DocumentEnhancingOperation.java
  79. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/EvaluationOperators.java
  80. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ExposedFields.java
  81. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ExposedFieldsAggregationOperationContext.java
  82. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/FacetOperation.java
  83. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Fields.java
  84. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/GeoNearOperation.java
  85. 26
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/GraphLookupOperation.java
  86. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/GroupOperation.java
  87. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/LimitOperation.java
  88. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/LiteralOperators.java
  89. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/LookupOperation.java
  90. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/MatchOperation.java
  91. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/MergeOperation.java
  92. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/NestedDelegatingExpressionAggregationOperationContext.java
  93. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ObjectOperators.java
  94. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/OutOperation.java
  95. 64
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperation.java
  96. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/RedactOperation.java
  97. 22
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ReplaceRootOperation.java
  98. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ReplaceWithOperation.java
  99. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/SampleOperation.java
  100. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ScriptOperators.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
spring-data-mongodb-benchmarks/src/main/java/org/springframework/data/mongodb/microbenchmark/AbstractMicrobenchmark.java

@ -322,7 +322,7 @@ public class AbstractMicrobenchmark {
try { try {
ResultsWriter.forUri(uri).write(results); ResultsWriter.forUri(uri).write(results);
} catch (Exception e) { } catch (Exception e) {
System.err.println(String.format("Cannot save benchmark results to '%s'. Error was %s.", uri, e)); System.err.println(String.format("Cannot save benchmark results to '%s'; Error was %s", uri, e));
} }
} }
} }

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/CodecRegistryProvider.java

@ -62,7 +62,7 @@ public interface CodecRegistryProvider {
*/ */
default <T> Optional<Codec<T>> getCodecFor(Class<T> type) { default <T> Optional<Codec<T>> getCodecFor(Class<T> type) {
Assert.notNull(type, "Type must not be null!"); Assert.notNull(type, "Type must not be null");
try { try {
return Optional.of(getCodecRegistry().get(type)); return Optional.of(getCodecRegistry().get(type));

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDatabaseUtils.java

@ -102,7 +102,7 @@ public class MongoDatabaseUtils {
private static MongoDatabase doGetMongoDatabase(@Nullable String dbName, MongoDatabaseFactory factory, private static MongoDatabase doGetMongoDatabase(@Nullable String dbName, MongoDatabaseFactory factory,
SessionSynchronization sessionSynchronization) { SessionSynchronization sessionSynchronization) {
Assert.notNull(factory, "Factory must not be null!"); Assert.notNull(factory, "Factory must not be null");
if (sessionSynchronization == SessionSynchronization.NEVER if (sessionSynchronization == SessionSynchronization.NEVER
|| !TransactionSynchronizationManager.isSynchronizationActive()) { || !TransactionSynchronizationManager.isSynchronizationActive()) {

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoResourceHolder.java

@ -68,7 +68,7 @@ class MongoResourceHolder extends ResourceHolderSupport {
ClientSession session = getSession(); ClientSession session = getSession();
if (session == null) { if (session == null) {
throw new IllegalStateException("No session available!"); throw new IllegalStateException("No session available");
} }
return session; return session;

10
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoTransactionManager.java

@ -100,7 +100,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
*/ */
public MongoTransactionManager(MongoDatabaseFactory dbFactory, @Nullable TransactionOptions options) { public MongoTransactionManager(MongoDatabaseFactory dbFactory, @Nullable TransactionOptions options) {
Assert.notNull(dbFactory, "DbFactory must not be null!"); Assert.notNull(dbFactory, "DbFactory must not be null");
this.dbFactory = dbFactory; this.dbFactory = dbFactory;
this.options = options; this.options = options;
@ -266,7 +266,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
*/ */
public void setDbFactory(MongoDatabaseFactory dbFactory) { public void setDbFactory(MongoDatabaseFactory dbFactory) {
Assert.notNull(dbFactory, "DbFactory must not be null!"); Assert.notNull(dbFactory, "DbFactory must not be null");
this.dbFactory = dbFactory; this.dbFactory = dbFactory;
} }
@ -315,7 +315,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
private MongoDatabaseFactory getRequiredDbFactory() { private MongoDatabaseFactory getRequiredDbFactory() {
Assert.state(dbFactory != null, Assert.state(dbFactory != null,
"MongoTransactionManager operates upon a MongoDbFactory. Did you forget to provide one? It's required."); "MongoTransactionManager operates upon a MongoDbFactory; Did you forget to provide one; It's required");
return dbFactory; return dbFactory;
} }
@ -450,14 +450,14 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
private MongoResourceHolder getRequiredResourceHolder() { private MongoResourceHolder getRequiredResourceHolder() {
Assert.state(resourceHolder != null, "MongoResourceHolder is required but not present. o_O"); Assert.state(resourceHolder != null, "MongoResourceHolder is required but not present; o_O");
return resourceHolder; return resourceHolder;
} }
private ClientSession getRequiredSession() { private ClientSession getRequiredSession() {
ClientSession session = getSession(); ClientSession session = getSession();
Assert.state(session != null, "A Session is required but it turned out to be null."); Assert.state(session != null, "A Session is required but it turned out to be null");
return session; return session;
} }

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/ReactiveMongoDatabaseUtils.java

@ -136,7 +136,7 @@ public class ReactiveMongoDatabaseUtils {
private static Mono<MongoDatabase> doGetMongoDatabase(@Nullable String dbName, ReactiveMongoDatabaseFactory factory, private static Mono<MongoDatabase> doGetMongoDatabase(@Nullable String dbName, ReactiveMongoDatabaseFactory factory,
SessionSynchronization sessionSynchronization) { SessionSynchronization sessionSynchronization) {
Assert.notNull(factory, "DatabaseFactory must not be null!"); Assert.notNull(factory, "DatabaseFactory must not be null");
if (sessionSynchronization == SessionSynchronization.NEVER) { if (sessionSynchronization == SessionSynchronization.NEVER) {
return getMongoDatabaseOrDefault(dbName, factory); return getMongoDatabaseOrDefault(dbName, factory);

10
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/ReactiveMongoTransactionManager.java

@ -104,7 +104,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
public ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory, public ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory,
@Nullable TransactionOptions options) { @Nullable TransactionOptions options) {
Assert.notNull(databaseFactory, "DatabaseFactory must not be null!"); Assert.notNull(databaseFactory, "DatabaseFactory must not be null");
this.databaseFactory = databaseFactory; this.databaseFactory = databaseFactory;
this.options = options; this.options = options;
@ -281,7 +281,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
*/ */
public void setDatabaseFactory(ReactiveMongoDatabaseFactory databaseFactory) { public void setDatabaseFactory(ReactiveMongoDatabaseFactory databaseFactory) {
Assert.notNull(databaseFactory, "DatabaseFactory must not be null!"); Assert.notNull(databaseFactory, "DatabaseFactory must not be null");
this.databaseFactory = databaseFactory; this.databaseFactory = databaseFactory;
} }
@ -323,7 +323,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
private ReactiveMongoDatabaseFactory getRequiredDatabaseFactory() { private ReactiveMongoDatabaseFactory getRequiredDatabaseFactory() {
Assert.state(databaseFactory != null, Assert.state(databaseFactory != null,
"ReactiveMongoTransactionManager operates upon a ReactiveMongoDatabaseFactory. Did you forget to provide one? It's required."); "ReactiveMongoTransactionManager operates upon a ReactiveMongoDatabaseFactory; Did you forget to provide one; It's required");
return databaseFactory; return databaseFactory;
} }
@ -458,14 +458,14 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
private ReactiveMongoResourceHolder getRequiredResourceHolder() { private ReactiveMongoResourceHolder getRequiredResourceHolder() {
Assert.state(resourceHolder != null, "ReactiveMongoResourceHolder is required but not present. o_O"); Assert.state(resourceHolder != null, "ReactiveMongoResourceHolder is required but not present; o_O");
return resourceHolder; return resourceHolder;
} }
private ClientSession getRequiredSession() { private ClientSession getRequiredSession() {
ClientSession session = getSession(); ClientSession session = getSession();
Assert.state(session != null, "A Session is required but it turned out to be null."); Assert.state(session != null, "A Session is required but it turned out to be null");
return session; return session;
} }

14
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/SessionAwareMethodInterceptor.java

@ -76,13 +76,13 @@ public class SessionAwareMethodInterceptor<D, C> implements MethodInterceptor {
Class<D> databaseType, ClientSessionOperator<D> databaseDecorator, Class<C> collectionType, Class<D> databaseType, ClientSessionOperator<D> databaseDecorator, Class<C> collectionType,
ClientSessionOperator<C> collectionDecorator) { ClientSessionOperator<C> collectionDecorator) {
Assert.notNull(session, "ClientSession must not be null!"); Assert.notNull(session, "ClientSession must not be null");
Assert.notNull(target, "Target must not be null!"); Assert.notNull(target, "Target must not be null");
Assert.notNull(sessionType, "SessionType must not be null!"); Assert.notNull(sessionType, "SessionType must not be null");
Assert.notNull(databaseType, "Database type must not be null!"); Assert.notNull(databaseType, "Database type must not be null");
Assert.notNull(databaseDecorator, "Database ClientSessionOperator must not be null!"); Assert.notNull(databaseDecorator, "Database ClientSessionOperator must not be null");
Assert.notNull(collectionType, "Collection type must not be null!"); Assert.notNull(collectionType, "Collection type must not be null");
Assert.notNull(collectionDecorator, "Collection ClientSessionOperator must not be null!"); Assert.notNull(collectionDecorator, "Collection ClientSessionOperator must not be null");
this.session = session; this.session = session;
this.target = target; this.target = target;

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

@ -255,7 +255,7 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
&& Boolean.parseBoolean(abbreviateFieldNames); && Boolean.parseBoolean(abbreviateFieldNames);
if (fieldNamingStrategyReferenced && abbreviationActivated) { if (fieldNamingStrategyReferenced && abbreviationActivated) {
context.error("Field name abbreviation cannot be activated if a field-naming-strategy-ref is configured!", context.error("Field name abbreviation cannot be activated if a field-naming-strategy-ref is configured",
element); element);
return; return;
} }

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

@ -55,8 +55,8 @@ class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
@Override @Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) { public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!"); Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null");
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
super.registerBeanDefinitions(annotationMetadata, registry); super.registerBeanDefinitions(annotationMetadata, registry);
} }
@ -64,7 +64,7 @@ class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
@Override @Override
protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) { protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) {
Assert.notNull(configuration, "AuditingConfiguration must not be null!"); Assert.notNull(configuration, "AuditingConfiguration must not be null");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(IsNewAwareAuditingHandler.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(IsNewAwareAuditingHandler.class);
@ -79,8 +79,8 @@ class MongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition, protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition,
BeanDefinitionRegistry registry) { BeanDefinitionRegistry registry) {
Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null!"); Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null");
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
BeanDefinitionBuilder listenerBeanDefinitionBuilder = BeanDefinitionBuilder BeanDefinitionBuilder listenerBeanDefinitionBuilder = BeanDefinitionBuilder
.rootBeanDefinition(AuditingEntityCallback.class); .rootBeanDefinition(AuditingEntityCallback.class);

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

@ -117,7 +117,7 @@ public class MongoCredentialPropertyEditor extends PropertyEditorSupport {
userNameAndPassword[1].toCharArray())); userNameAndPassword[1].toCharArray()));
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException(
String.format("Cannot create MongoCredentials for unknown auth mechanism '%s'!", authMechanism)); String.format("Cannot create MongoCredentials for unknown auth mechanism '%s'", authMechanism));
} }
} }
} else { } else {
@ -194,7 +194,7 @@ public class MongoCredentialPropertyEditor extends PropertyEditorSupport {
String[] optionArgs = option.split("="); String[] optionArgs = option.split("=");
if (optionArgs.length == 1) { if (optionArgs.length == 1) {
throw new IllegalArgumentException(String.format("Query parameter '%s' has no value!", optionArgs[0])); throw new IllegalArgumentException(String.format("Query parameter '%s' has no value", optionArgs[0]));
} }
properties.put(optionArgs[0], optionArgs[1]); properties.put(optionArgs[0], optionArgs[1]);
@ -209,21 +209,21 @@ public class MongoCredentialPropertyEditor extends PropertyEditorSupport {
if (source.length != 2) { if (source.length != 2) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Credentials need to specify username and password like in 'username:password@database'!"); "Credentials need to specify username and password like in 'username:password@database'");
} }
} }
private static void verifyDatabasePresent(String source) { private static void verifyDatabasePresent(String source) {
if (!StringUtils.hasText(source)) { if (!StringUtils.hasText(source)) {
throw new IllegalArgumentException("Credentials need to specify database like in 'username:password@database'!"); throw new IllegalArgumentException("Credentials need to specify database like in 'username:password@database'");
} }
} }
private static void verifyUserNamePresent(String[] source) { private static void verifyUserNamePresent(String[] source) {
if (source.length == 0 || !StringUtils.hasText(source[0])) { if (source.length == 0 || !StringUtils.hasText(source[0])) {
throw new IllegalArgumentException("Credentials need to specify username!"); throw new IllegalArgumentException("Credentials need to specify username");
} }
} }
@ -231,7 +231,7 @@ public class MongoCredentialPropertyEditor extends PropertyEditorSupport {
try { try {
return URLDecoder.decode(it, "UTF-8"); return URLDecoder.decode(it, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("o_O UTF-8 not supported!", e); throw new IllegalArgumentException("o_O UTF-8 not supported", e);
} }
} }
} }

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

@ -163,7 +163,7 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
if (element.getAttributes().getLength() > allowedAttributesCount) { if (element.getAttributes().getLength() > allowedAttributesCount) {
parserContext.getReaderContext().error("Configure either MongoDB " + type + " or details individually!", parserContext.getReaderContext().error("Configure either MongoDB " + type + " or details individually",
parserContext.extractSource(element)); parserContext.extractSource(element));
} }

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

@ -51,7 +51,7 @@ class ReactiveMongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupp
@Override @Override
protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) { protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) {
Assert.notNull(configuration, "AuditingConfiguration must not be null!"); Assert.notNull(configuration, "AuditingConfiguration must not be null");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveIsNewAwareAuditingHandler.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveIsNewAwareAuditingHandler.class);
@ -66,8 +66,8 @@ class ReactiveMongoAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupp
protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition, protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition,
BeanDefinitionRegistry registry) { BeanDefinitionRegistry registry) {
Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null!"); Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null");
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveAuditingEntityCallback.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ReactiveAuditingEntityCallback.class);

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

@ -43,7 +43,7 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
* A port is a number without a leading 0 at the end of the address that is proceeded by just a single :. * A port is a number without a leading 0 at the end of the address that is proceeded by just a single :.
*/ */
private static final String HOST_PORT_SPLIT_PATTERN = "(?<!:):(?=[123456789]\\d*$)"; private static final String HOST_PORT_SPLIT_PATTERN = "(?<!:):(?=[123456789]\\d*$)";
private static final String COULD_NOT_PARSE_ADDRESS_MESSAGE = "Could not parse address %s '%s'. Check your replica set configuration!"; private static final String COULD_NOT_PARSE_ADDRESS_MESSAGE = "Could not parse address %s '%s'; Check your replica set configuration";
private static final Log LOG = LogFactory.getLog(ServerAddressPropertyEditor.class); private static final Log LOG = LogFactory.getLog(ServerAddressPropertyEditor.class);
@Override @Override
@ -68,7 +68,7 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
if (serverAddresses.isEmpty()) { if (serverAddresses.isEmpty()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Could not resolve at least one server of the replica set configuration! Validate your config!"); "Could not resolve at least one server of the replica set configuration; Validate your config");
} }
setValue(serverAddresses.toArray(new ServerAddress[serverAddresses.size()])); setValue(serverAddresses.toArray(new ServerAddress[serverAddresses.size()]));
@ -125,7 +125,7 @@ public class ServerAddressPropertyEditor extends PropertyEditorSupport {
*/ */
private String[] extractHostAddressAndPort(String addressAndPortSource) { private String[] extractHostAddressAndPort(String addressAndPortSource) {
Assert.notNull(addressAndPortSource, "Address and port source must not be null!"); Assert.notNull(addressAndPortSource, "Address and port source must not be null");
String[] hostAndPort = addressAndPortSource.split(HOST_PORT_SPLIT_PATTERN); String[] hostAndPort = addressAndPortSource.split(HOST_PORT_SPLIT_PATTERN);
String hostAddress = hostAndPort[0]; String hostAddress = hostAndPort[0];

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

@ -148,7 +148,7 @@ public class ChangeStreamOptions {
} }
throw new IllegalArgumentException( throw new IllegalArgumentException(
"o_O that should actually not happen. The timestamp should be an Instant or a BsonTimestamp but was " "o_O that should actually not happen; The timestamp should be an Instant or a BsonTimestamp but was "
+ ObjectUtils.nullSafeClassName(timestamp)); + ObjectUtils.nullSafeClassName(timestamp));
} }
@ -234,7 +234,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder collation(Collation collation) { public ChangeStreamOptionsBuilder collation(Collation collation) {
Assert.notNull(collation, "Collation must not be null nor empty!"); Assert.notNull(collation, "Collation must not be null nor empty");
this.collation = collation; this.collation = collation;
return this; return this;
@ -258,7 +258,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder filter(Aggregation filter) { public ChangeStreamOptionsBuilder filter(Aggregation filter) {
Assert.notNull(filter, "Filter must not be null!"); Assert.notNull(filter, "Filter must not be null");
this.filter = filter; this.filter = filter;
return this; return this;
@ -287,7 +287,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder resumeToken(BsonValue resumeToken) { public ChangeStreamOptionsBuilder resumeToken(BsonValue resumeToken) {
Assert.notNull(resumeToken, "ResumeToken must not be null!"); Assert.notNull(resumeToken, "ResumeToken must not be null");
this.resumeToken = resumeToken; this.resumeToken = resumeToken;
@ -316,7 +316,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder fullDocumentLookup(FullDocument lookup) { public ChangeStreamOptionsBuilder fullDocumentLookup(FullDocument lookup) {
Assert.notNull(lookup, "Lookup must not be null!"); Assert.notNull(lookup, "Lookup must not be null");
this.fullDocumentLookup = lookup; this.fullDocumentLookup = lookup;
return this; return this;
@ -330,7 +330,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder resumeAt(Instant resumeTimestamp) { public ChangeStreamOptionsBuilder resumeAt(Instant resumeTimestamp) {
Assert.notNull(resumeTimestamp, "ResumeTimestamp must not be null!"); Assert.notNull(resumeTimestamp, "ResumeTimestamp must not be null");
this.resumeTimestamp = resumeTimestamp; this.resumeTimestamp = resumeTimestamp;
return this; return this;
@ -345,7 +345,7 @@ public class ChangeStreamOptions {
*/ */
public ChangeStreamOptionsBuilder resumeAt(BsonTimestamp resumeTimestamp) { public ChangeStreamOptionsBuilder resumeAt(BsonTimestamp resumeTimestamp) {
Assert.notNull(resumeTimestamp, "ResumeTimestamp must not be null!"); Assert.notNull(resumeTimestamp, "ResumeTimestamp must not be null");
this.resumeTimestamp = resumeTimestamp; this.resumeTimestamp = resumeTimestamp;
return this; return this;

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

@ -68,7 +68,7 @@ public class CollectionOptions {
*/ */
public static CollectionOptions just(Collation collation) { public static CollectionOptions just(Collation collation) {
Assert.notNull(collation, "Collation must not be null!"); Assert.notNull(collation, "Collation must not be null");
return new CollectionOptions(null, null, null, collation, ValidationOptions.none(), null); return new CollectionOptions(null, null, null, collation, ValidationOptions.none(), null);
} }
@ -230,7 +230,7 @@ public class CollectionOptions {
*/ */
public CollectionOptions schemaValidationLevel(ValidationLevel validationLevel) { public CollectionOptions schemaValidationLevel(ValidationLevel validationLevel) {
Assert.notNull(validationLevel, "ValidationLevel must not be null!"); Assert.notNull(validationLevel, "ValidationLevel must not be null");
return validation(validationOptions.validationLevel(validationLevel)); return validation(validationOptions.validationLevel(validationLevel));
} }
@ -244,7 +244,7 @@ public class CollectionOptions {
*/ */
public CollectionOptions schemaValidationAction(ValidationAction validationAction) { public CollectionOptions schemaValidationAction(ValidationAction validationAction) {
Assert.notNull(validationAction, "ValidationAction must not be null!"); Assert.notNull(validationAction, "ValidationAction must not be null");
return validation(validationOptions.validationAction(validationAction)); return validation(validationOptions.validationAction(validationAction));
} }
@ -257,7 +257,7 @@ public class CollectionOptions {
*/ */
public CollectionOptions validation(ValidationOptions validationOptions) { public CollectionOptions validation(ValidationOptions validationOptions) {
Assert.notNull(validationOptions, "ValidationOptions must not be null!"); Assert.notNull(validationOptions, "ValidationOptions must not be null");
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions); return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
} }
@ -270,7 +270,7 @@ public class CollectionOptions {
*/ */
public CollectionOptions timeSeries(TimeSeriesOptions timeSeriesOptions) { public CollectionOptions timeSeries(TimeSeriesOptions timeSeriesOptions) {
Assert.notNull(timeSeriesOptions, "TimeSeriesOptions must not be null!"); Assert.notNull(timeSeriesOptions, "TimeSeriesOptions must not be null");
return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions); return new CollectionOptions(size, maxDocuments, capped, collation, validationOptions, timeSeriesOptions);
} }
@ -446,7 +446,7 @@ public class CollectionOptions {
private TimeSeriesOptions(String timeField, @Nullable String metaField, GranularityDefinition granularity) { private TimeSeriesOptions(String timeField, @Nullable String metaField, GranularityDefinition granularity) {
Assert.hasText(timeField, "Time field must not be empty or null!"); Assert.hasText(timeField, "Time field must not be empty or null");
this.timeField = timeField; this.timeField = timeField;
this.metaField = metaField; this.metaField = metaField;

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

@ -183,7 +183,7 @@ class CountQuery {
criteria.addAll((Collection) $and); criteria.addAll((Collection) $and);
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot rewrite query as it contains an '$and' element that is not a Collection!: Offending element: " "Cannot rewrite query as it contains an '$and' element that is not a Collection: Offending element: "
+ $and); + $and);
} }
} }

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

@ -61,8 +61,8 @@ public interface CursorPreparer extends ReadPreferenceAware {
default FindIterable<Document> initiateFind(MongoCollection<Document> collection, default FindIterable<Document> initiateFind(MongoCollection<Document> collection,
Function<MongoCollection<Document>, FindIterable<Document>> find) { Function<MongoCollection<Document>, FindIterable<Document>> find) {
Assert.notNull(collection, "Collection must not be null!"); Assert.notNull(collection, "Collection must not be null");
Assert.notNull(find, "Find function must not be null!"); Assert.notNull(find, "Find function must not be null");
if (hasReadPreference()) { if (hasReadPreference()) {
collection = collection.withReadPreference(getReadPreference()); collection = collection.withReadPreference(getReadPreference());

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

@ -90,9 +90,9 @@ class DefaultBulkOperations implements BulkOperations {
DefaultBulkOperations(MongoOperations mongoOperations, String collectionName, DefaultBulkOperations(MongoOperations mongoOperations, String collectionName,
BulkOperationContext bulkOperationContext) { BulkOperationContext bulkOperationContext) {
Assert.notNull(mongoOperations, "MongoOperations must not be null!"); Assert.notNull(mongoOperations, "MongoOperations must not be null");
Assert.hasText(collectionName, "CollectionName must not be null nor empty!"); Assert.hasText(collectionName, "CollectionName must not be null nor empty");
Assert.notNull(bulkOperationContext, "BulkOperationContext must not be null!"); Assert.notNull(bulkOperationContext, "BulkOperationContext must not be null");
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
this.collectionName = collectionName; this.collectionName = collectionName;
@ -112,7 +112,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations insert(Object document) { public BulkOperations insert(Object document) {
Assert.notNull(document, "Document must not be null!"); Assert.notNull(document, "Document must not be null");
maybeEmitEvent(new BeforeConvertEvent<>(document, collectionName)); maybeEmitEvent(new BeforeConvertEvent<>(document, collectionName));
Object source = maybeInvokeBeforeConvertCallback(document); Object source = maybeInvokeBeforeConvertCallback(document);
@ -124,7 +124,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations insert(List<? extends Object> documents) { public BulkOperations insert(List<? extends Object> documents) {
Assert.notNull(documents, "Documents must not be null!"); Assert.notNull(documents, "Documents must not be null");
documents.forEach(this::insert); documents.forEach(this::insert);
@ -135,8 +135,8 @@ class DefaultBulkOperations implements BulkOperations {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public BulkOperations updateOne(Query query, Update update) { public BulkOperations updateOne(Query query, Update update) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
return updateOne(Collections.singletonList(Pair.of(query, update))); return updateOne(Collections.singletonList(Pair.of(query, update)));
} }
@ -144,7 +144,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations updateOne(List<Pair<Query, Update>> updates) { public BulkOperations updateOne(List<Pair<Query, Update>> updates) {
Assert.notNull(updates, "Updates must not be null!"); Assert.notNull(updates, "Updates must not be null");
for (Pair<Query, Update> update : updates) { for (Pair<Query, Update> update : updates) {
update(update.getFirst(), update.getSecond(), false, false); update(update.getFirst(), update.getSecond(), false, false);
@ -157,8 +157,8 @@ class DefaultBulkOperations implements BulkOperations {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public BulkOperations updateMulti(Query query, Update update) { public BulkOperations updateMulti(Query query, Update update) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
return updateMulti(Collections.singletonList(Pair.of(query, update))); return updateMulti(Collections.singletonList(Pair.of(query, update)));
} }
@ -166,7 +166,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations updateMulti(List<Pair<Query, Update>> updates) { public BulkOperations updateMulti(List<Pair<Query, Update>> updates) {
Assert.notNull(updates, "Updates must not be null!"); Assert.notNull(updates, "Updates must not be null");
for (Pair<Query, Update> update : updates) { for (Pair<Query, Update> update : updates) {
update(update.getFirst(), update.getSecond(), false, true); update(update.getFirst(), update.getSecond(), false, true);
@ -193,7 +193,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations remove(Query query) { public BulkOperations remove(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
DeleteOptions deleteOptions = new DeleteOptions(); DeleteOptions deleteOptions = new DeleteOptions();
query.getCollation().map(Collation::toMongoCollation).ifPresent(deleteOptions::collation); query.getCollation().map(Collation::toMongoCollation).ifPresent(deleteOptions::collation);
@ -206,7 +206,7 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations remove(List<Query> removes) { public BulkOperations remove(List<Query> removes) {
Assert.notNull(removes, "Removals must not be null!"); Assert.notNull(removes, "Removals must not be null");
for (Query query : removes) { for (Query query : removes) {
remove(query); remove(query);
@ -218,9 +218,9 @@ class DefaultBulkOperations implements BulkOperations {
@Override @Override
public BulkOperations replaceOne(Query query, Object replacement, FindAndReplaceOptions options) { public BulkOperations replaceOne(Query query, Object replacement, FindAndReplaceOptions options) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
ReplaceOptions replaceOptions = new ReplaceOptions(); ReplaceOptions replaceOptions = new ReplaceOptions();
replaceOptions.upsert(options.isUpsert()); replaceOptions.upsert(options.isUpsert());
@ -241,7 +241,7 @@ class DefaultBulkOperations implements BulkOperations {
com.mongodb.bulk.BulkWriteResult result = mongoOperations.execute(collectionName, this::bulkWriteTo); com.mongodb.bulk.BulkWriteResult result = mongoOperations.execute(collectionName, this::bulkWriteTo);
Assert.state(result != null, "Result must not be null."); Assert.state(result != null, "Result must not be null");
models.forEach(this::maybeEmitAfterSaveEvent); models.forEach(this::maybeEmitAfterSaveEvent);
models.forEach(this::maybeInvokeAfterSaveCallback); models.forEach(this::maybeInvokeAfterSaveCallback);
@ -308,8 +308,8 @@ class DefaultBulkOperations implements BulkOperations {
*/ */
private BulkOperations update(Query query, Update update, boolean upsert, boolean multi) { private BulkOperations update(Query query, Update update, boolean upsert, boolean multi) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
UpdateOptions options = computeUpdateOptions(query, update, upsert); UpdateOptions options = computeUpdateOptions(query, update, upsert);
@ -470,7 +470,7 @@ class DefaultBulkOperations implements BulkOperations {
return options.ordered(false); return options.ordered(false);
} }
throw new IllegalStateException("BulkMode was null!"); throw new IllegalStateException("BulkMode was null");
} }
/** /**

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

@ -83,9 +83,9 @@ public class DefaultIndexOperations implements IndexOperations {
public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper, public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper,
@Nullable Class<?> type) { @Nullable Class<?> type) {
Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!"); Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null");
Assert.notNull(collectionName, "Collection name can not be null!"); Assert.notNull(collectionName, "Collection name can not be null");
Assert.notNull(queryMapper, "QueryMapper must not be null!"); Assert.notNull(queryMapper, "QueryMapper must not be null");
this.collectionName = collectionName; this.collectionName = collectionName;
this.mapper = queryMapper; this.mapper = queryMapper;
@ -103,8 +103,8 @@ public class DefaultIndexOperations implements IndexOperations {
*/ */
public DefaultIndexOperations(MongoOperations mongoOperations, String collectionName, @Nullable Class<?> type) { public DefaultIndexOperations(MongoOperations mongoOperations, String collectionName, @Nullable Class<?> type) {
Assert.notNull(mongoOperations, "MongoOperations must not be null!"); Assert.notNull(mongoOperations, "MongoOperations must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
this.mapper = new QueryMapper(mongoOperations.getConverter()); this.mapper = new QueryMapper(mongoOperations.getConverter());
@ -189,7 +189,7 @@ public class DefaultIndexOperations implements IndexOperations {
@Nullable @Nullable
public <T> T execute(CollectionCallback<T> callback) { public <T> T execute(CollectionCallback<T> callback) {
Assert.notNull(callback, "CollectionCallback must not be null!"); Assert.notNull(callback, "CollectionCallback must not be null");
if (type != null) { if (type != null) {
return mongoOperations.execute(type, callback); return mongoOperations.execute(type, callback);

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

@ -76,9 +76,9 @@ public class DefaultReactiveIndexOperations implements ReactiveIndexOperations {
private DefaultReactiveIndexOperations(ReactiveMongoOperations mongoOperations, String collectionName, private DefaultReactiveIndexOperations(ReactiveMongoOperations mongoOperations, String collectionName,
QueryMapper queryMapper, Optional<Class<?>> type) { QueryMapper queryMapper, Optional<Class<?>> type) {
Assert.notNull(mongoOperations, "ReactiveMongoOperations must not be null!"); Assert.notNull(mongoOperations, "ReactiveMongoOperations must not be null");
Assert.notNull(collectionName, "Collection must not be null!"); Assert.notNull(collectionName, "Collection must not be null");
Assert.notNull(queryMapper, "QueryMapper must not be null!"); Assert.notNull(queryMapper, "QueryMapper must not be null");
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
this.collectionName = collectionName; this.collectionName = collectionName;

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

@ -65,7 +65,7 @@ class DefaultScriptOperations implements ScriptOperations {
*/ */
public DefaultScriptOperations(MongoOperations mongoOperations) { public DefaultScriptOperations(MongoOperations mongoOperations) {
Assert.notNull(mongoOperations, "MongoOperations must not be null!"); Assert.notNull(mongoOperations, "MongoOperations must not be null");
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
} }
@ -78,7 +78,7 @@ class DefaultScriptOperations implements ScriptOperations {
@Override @Override
public NamedMongoScript register(NamedMongoScript script) { public NamedMongoScript register(NamedMongoScript script) {
Assert.notNull(script, "Script must not be null!"); Assert.notNull(script, "Script must not be null");
mongoOperations.save(script, SCRIPT_COLLECTION_NAME); mongoOperations.save(script, SCRIPT_COLLECTION_NAME);
return script; return script;
@ -87,7 +87,7 @@ class DefaultScriptOperations implements ScriptOperations {
@Override @Override
public Object execute(final ExecutableMongoScript script, final Object... args) { public Object execute(final ExecutableMongoScript script, final Object... args) {
Assert.notNull(script, "Script must not be null!"); Assert.notNull(script, "Script must not be null");
return mongoOperations.execute(new DbCallback<Object>() { return mongoOperations.execute(new DbCallback<Object>() {
@ -106,7 +106,7 @@ class DefaultScriptOperations implements ScriptOperations {
@Override @Override
public Object call(final String scriptName, final Object... args) { public Object call(final String scriptName, final Object... args) {
Assert.hasText(scriptName, "ScriptName must not be null or empty!"); Assert.hasText(scriptName, "ScriptName must not be null or empty");
return mongoOperations.execute(new DbCallback<Object>() { return mongoOperations.execute(new DbCallback<Object>() {
@ -122,7 +122,7 @@ class DefaultScriptOperations implements ScriptOperations {
@Override @Override
public boolean exists(String scriptName) { public boolean exists(String scriptName) {
Assert.hasText(scriptName, "ScriptName must not be null or empty!"); Assert.hasText(scriptName, "ScriptName must not be null or empty");
return mongoOperations.exists(query(where("_id").is(scriptName)), NamedMongoScript.class, SCRIPT_COLLECTION_NAME); return mongoOperations.exists(query(where("_id").is(scriptName)), NamedMongoScript.class, SCRIPT_COLLECTION_NAME);
} }

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

@ -112,7 +112,7 @@ class EntityOperations {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
<T> Entity<T> forEntity(T entity) { <T> Entity<T> forEntity(T entity) {
Assert.notNull(entity, "Bean must not be null!"); Assert.notNull(entity, "Bean must not be null");
if (entity instanceof String) { if (entity instanceof String) {
return new UnmappedEntity(parse(entity.toString())); return new UnmappedEntity(parse(entity.toString()));
@ -135,8 +135,8 @@ class EntityOperations {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
<T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) { <T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) {
Assert.notNull(entity, "Bean must not be null!"); Assert.notNull(entity, "Bean must not be null");
Assert.notNull(conversionService, "ConversionService must not be null!"); Assert.notNull(conversionService, "ConversionService must not be null");
if (entity instanceof String) { if (entity instanceof String) {
return new UnmappedEntity(parse(entity.toString())); return new UnmappedEntity(parse(entity.toString()));
@ -171,7 +171,7 @@ class EntityOperations {
if (entityClass == null) { if (entityClass == null) {
throw new InvalidDataAccessApiUsageException( throw new InvalidDataAccessApiUsageException(
"No class parameter provided, entity collection can't be determined!"); "No class parameter provided, entity collection can't be determined");
} }
return context.getRequiredPersistentEntity(entityClass).getCollection(); return context.getRequiredPersistentEntity(entityClass).getCollection();
@ -201,7 +201,7 @@ class EntityOperations {
*/ */
public String getIdPropertyName(Class<?> type) { public String getIdPropertyName(Class<?> type) {
Assert.notNull(type, "Type must not be null!"); Assert.notNull(type, "Type must not be null");
MongoPersistentEntity<?> persistentEntity = context.getPersistentEntity(type); MongoPersistentEntity<?> persistentEntity = context.getPersistentEntity(type);
@ -240,12 +240,12 @@ class EntityOperations {
try { try {
return Document.parse(source); return Document.parse(source);
} catch (org.bson.json.JsonParseException o_O) { } catch (org.bson.json.JsonParseException o_O) {
throw new MappingException("Could not parse given String to save into a JSON document!", o_O); throw new MappingException("Could not parse given String to save into a JSON document", o_O);
} catch (RuntimeException o_O) { } catch (RuntimeException o_O) {
// legacy 3.x exception // legacy 3.x exception
if (ClassUtils.matchesTypeName(o_O.getClass(), "JSONParseException")) { if (ClassUtils.matchesTypeName(o_O.getClass(), "JSONParseException")) {
throw new MappingException("Could not parse given String to save into a JSON document!", o_O); throw new MappingException("Could not parse given String to save into a JSON document", o_O);
} }
throw o_O; throw o_O;
} }
@ -518,7 +518,7 @@ class EntityOperations {
@Override @Override
public Query getQueryForVersion() { public Query getQueryForVersion() {
throw new MappingException("Cannot query for version on plain Documents!"); throw new MappingException("Cannot query for version on plain Documents");
} }
@Override @Override
@ -614,7 +614,7 @@ class EntityOperations {
public Query getByIdQuery() { public Query getByIdQuery() {
if (!entity.hasIdProperty()) { if (!entity.hasIdProperty()) {
throw new MappingException("No id property found for object of type " + entity.getType() + "!"); throw new MappingException("No id property found for object of type " + entity.getType());
} }
MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
@ -662,7 +662,7 @@ class EntityOperations {
if (!MongoSimpleTypes.AUTOGENERATED_ID_TYPES.contains(property.getType())) { if (!MongoSimpleTypes.AUTOGENERATED_ID_TYPES.contains(property.getType())) {
throw new InvalidDataAccessApiUsageException( throw new InvalidDataAccessApiUsageException(
String.format("Cannot autogenerate id of type %s for entity of type %s!", property.getType().getName(), String.format("Cannot autogenerate id of type %s for entity of type %s", property.getType().getName(),
entity.getType().getName())); entity.getType().getName()));
} }
} }

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

@ -41,7 +41,7 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
@Override @Override
public <T> ExecutableAggregation<T> aggregateAndReturn(Class<T> domainType) { public <T> ExecutableAggregation<T> aggregateAndReturn(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableAggregationSupport<>(template, domainType, null, null); return new ExecutableAggregationSupport<>(template, domainType, null, null);
} }
@ -69,7 +69,7 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
@Override @Override
public AggregationWithAggregation<T> inCollection(String collection) { public AggregationWithAggregation<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ExecutableAggregationSupport<>(template, domainType, aggregation, collection); return new ExecutableAggregationSupport<>(template, domainType, aggregation, collection);
} }
@ -77,7 +77,7 @@ class ExecutableAggregationOperationSupport implements ExecutableAggregationOper
@Override @Override
public TerminatingAggregation<T> by(Aggregation aggregation) { public TerminatingAggregation<T> by(Aggregation aggregation) {
Assert.notNull(aggregation, "Aggregation must not be null!"); Assert.notNull(aggregation, "Aggregation must not be null");
return new ExecutableAggregationSupport<>(template, domainType, aggregation, collection); return new ExecutableAggregationSupport<>(template, domainType, aggregation, collection);
} }

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

@ -53,7 +53,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public <T> ExecutableFind<T> query(Class<T> domainType) { public <T> ExecutableFind<T> query(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableFindSupport<>(template, domainType, domainType, null, ALL_QUERY); return new ExecutableFindSupport<>(template, domainType, domainType, null, ALL_QUERY);
} }
@ -84,7 +84,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public FindWithProjection<T> inCollection(String collection) { public FindWithProjection<T> inCollection(String collection) {
Assert.hasText(collection, "Collection name must not be null nor empty!"); Assert.hasText(collection, "Collection name must not be null nor empty");
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query); return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -92,7 +92,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public <T1> FindWithQuery<T1> as(Class<T1> returnType) { public <T1> FindWithQuery<T1> as(Class<T1> returnType) {
Assert.notNull(returnType, "ReturnType must not be null!"); Assert.notNull(returnType, "ReturnType must not be null");
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query); return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -100,7 +100,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public TerminatingFind<T> matching(Query query) { public TerminatingFind<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ExecutableFindSupport<>(template, domainType, returnType, collection, query); return new ExecutableFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -115,7 +115,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
} }
if (result.size() > 1) { if (result.size() > 1) {
throw new IncorrectResultSizeDataAccessException("Query " + asString() + " returned non unique result.", 1); throw new IncorrectResultSizeDataAccessException("Query " + asString() + " returned non unique result", 1);
} }
return result.iterator().next(); return result.iterator().next();
@ -158,7 +158,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public TerminatingDistinct<Object> distinct(String field) { public TerminatingDistinct<Object> distinct(String field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
return new DistinctOperationSupport(this, field); return new DistinctOperationSupport(this, field);
} }
@ -246,7 +246,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <R> TerminatingDistinct<R> as(Class<R> resultType) { public <R> TerminatingDistinct<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new DistinctOperationSupport<>((ExecutableFindSupport) delegate.as(resultType), field); return new DistinctOperationSupport<>((ExecutableFindSupport) delegate.as(resultType), field);
} }
@ -254,7 +254,7 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
@Override @Override
public TerminatingDistinct<T> matching(Query query) { public TerminatingDistinct<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new DistinctOperationSupport<>((ExecutableFindSupport<T>) delegate.matching(query), field); return new DistinctOperationSupport<>((ExecutableFindSupport<T>) delegate.matching(query), field);
} }

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

@ -43,7 +43,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public <T> ExecutableInsert<T> insert(Class<T> domainType) { public <T> ExecutableInsert<T> insert(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableInsertSupport<>(template, domainType, null, null); return new ExecutableInsertSupport<>(template, domainType, null, null);
} }
@ -70,7 +70,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public T one(T object) { public T one(T object) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
return template.insert(object, getCollectionName()); return template.insert(object, getCollectionName());
} }
@ -78,7 +78,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public Collection<T> all(Collection<? extends T> objects) { public Collection<T> all(Collection<? extends T> objects) {
Assert.notNull(objects, "Objects must not be null!"); Assert.notNull(objects, "Objects must not be null");
return template.insert(objects, getCollectionName()); return template.insert(objects, getCollectionName());
} }
@ -86,7 +86,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public BulkWriteResult bulk(Collection<? extends T> objects) { public BulkWriteResult bulk(Collection<? extends T> objects) {
Assert.notNull(objects, "Objects must not be null!"); Assert.notNull(objects, "Objects must not be null");
return template.bulkOps(bulkMode != null ? bulkMode : BulkMode.ORDERED, domainType, getCollectionName()) return template.bulkOps(bulkMode != null ? bulkMode : BulkMode.ORDERED, domainType, getCollectionName())
.insert(new ArrayList<>(objects)).execute(); .insert(new ArrayList<>(objects)).execute();
@ -95,7 +95,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public InsertWithBulkMode<T> inCollection(String collection) { public InsertWithBulkMode<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty."); Assert.hasText(collection, "Collection must not be null nor empty");
return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode); return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode);
} }
@ -103,7 +103,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
@Override @Override
public TerminatingBulkInsert<T> withBulkMode(BulkMode bulkMode) { public TerminatingBulkInsert<T> withBulkMode(BulkMode bulkMode) {
Assert.notNull(bulkMode, "BulkMode must not be null!"); Assert.notNull(bulkMode, "BulkMode must not be null");
return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode); return new ExecutableInsertSupport<>(template, domainType, collection, bulkMode);
} }

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

@ -37,7 +37,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
ExecutableMapReduceOperationSupport(MongoTemplate template) { ExecutableMapReduceOperationSupport(MongoTemplate template) {
Assert.notNull(template, "Template must not be null!"); Assert.notNull(template, "Template must not be null");
this.template = template; this.template = template;
} }
@ -48,7 +48,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public <T> ExecutableMapReduceSupport<T> mapReduce(Class<T> domainType) { public <T> ExecutableMapReduceSupport<T> mapReduce(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableMapReduceSupport<>(template, domainType, domainType, null, ALL_QUERY, null, null, null); return new ExecutableMapReduceSupport<>(template, domainType, domainType, null, ALL_QUERY, null, null, null);
} }
@ -101,7 +101,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public MapReduceWithProjection<T> inCollection(String collection) { public MapReduceWithProjection<T> inCollection(String collection) {
Assert.hasText(collection, "Collection name must not be null nor empty!"); Assert.hasText(collection, "Collection name must not be null nor empty");
return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -114,7 +114,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public TerminatingMapReduce<T> matching(Query query) { public TerminatingMapReduce<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -127,7 +127,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public <R> MapReduceWithQuery<R> as(Class<R> resultType) { public <R> MapReduceWithQuery<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new ExecutableMapReduceSupport<>(template, domainType, resultType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, resultType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -140,7 +140,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public ExecutableMapReduce<T> with(MapReduceOptions options) { public ExecutableMapReduce<T> with(MapReduceOptions options) {
Assert.notNull(options, "Options must not be null! Please consider empty MapReduceOptions#options() instead."); Assert.notNull(options, "Options must not be null Please consider empty MapReduceOptions#options() instead");
return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -153,7 +153,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public MapReduceWithReduceFunction<T> map(String mapFunction) { public MapReduceWithReduceFunction<T> map(String mapFunction) {
Assert.hasText(mapFunction, "MapFunction name must not be null nor empty!"); Assert.hasText(mapFunction, "MapFunction name must not be null nor empty");
return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -166,7 +166,7 @@ class ExecutableMapReduceOperationSupport implements ExecutableMapReduceOperatio
@Override @Override
public ExecutableMapReduce<T> reduce(String reduceFunction) { public ExecutableMapReduce<T> reduce(String reduceFunction) {
Assert.hasText(reduceFunction, "ReduceFunction name must not be null nor empty!"); Assert.hasText(reduceFunction, "ReduceFunction name must not be null nor empty");
return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ExecutableMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);

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

@ -44,7 +44,7 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
@Override @Override
public <T> ExecutableRemove<T> remove(Class<T> domainType) { public <T> ExecutableRemove<T> remove(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableRemoveSupport<>(tempate, domainType, ALL_QUERY, null); return new ExecutableRemoveSupport<>(tempate, domainType, ALL_QUERY, null);
} }
@ -70,7 +70,7 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
@Override @Override
public RemoveWithQuery<T> inCollection(String collection) { public RemoveWithQuery<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ExecutableRemoveSupport<>(template, domainType, query, collection); return new ExecutableRemoveSupport<>(template, domainType, query, collection);
} }
@ -78,7 +78,7 @@ class ExecutableRemoveOperationSupport implements ExecutableRemoveOperation {
@Override @Override
public TerminatingRemove<T> matching(Query query) { public TerminatingRemove<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ExecutableRemoveSupport<>(template, domainType, query, collection); return new ExecutableRemoveSupport<>(template, domainType, query, collection);
} }

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

@ -43,7 +43,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public <T> ExecutableUpdate<T> update(Class<T> domainType) { public <T> ExecutableUpdate<T> update(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ExecutableUpdateSupport<>(template, domainType, ALL_QUERY, null, null, null, null, null, domainType); return new ExecutableUpdateSupport<>(template, domainType, ALL_QUERY, null, null, null, null, null, domainType);
} }
@ -84,7 +84,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public TerminatingUpdate<T> apply(UpdateDefinition update) { public TerminatingUpdate<T> apply(UpdateDefinition update) {
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -93,7 +93,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public UpdateWithQuery<T> inCollection(String collection) { public UpdateWithQuery<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -102,7 +102,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options) { public TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options) {
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, options, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, options,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -111,7 +111,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public FindAndReplaceWithProjection<T> replaceWith(T replacement) { public FindAndReplaceWithProjection<T> replaceWith(T replacement) {
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -120,7 +120,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public FindAndReplaceWithProjection<T> withOptions(FindAndReplaceOptions options) { public FindAndReplaceWithProjection<T> withOptions(FindAndReplaceOptions options) {
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
options, replacement, targetType); options, replacement, targetType);
@ -129,7 +129,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public UpdateWithUpdate<T> matching(Query query) { public UpdateWithUpdate<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -138,7 +138,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
@Override @Override
public <R> FindAndReplaceWithOptions<R> as(Class<R> resultType) { public <R> FindAndReplaceWithOptions<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ExecutableUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, resultType); findAndReplaceOptions, replacement, resultType);

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

@ -35,7 +35,7 @@ public class FindAndModifyOptions {
private static final FindAndModifyOptions NONE = new FindAndModifyOptions() { private static final FindAndModifyOptions NONE = new FindAndModifyOptions() {
private static final String ERROR_MSG = "FindAndModifyOptions.none() cannot be changed. Please use FindAndModifyOptions.options() instead."; private static final String ERROR_MSG = "FindAndModifyOptions.none() cannot be changed; Please use FindAndModifyOptions.options() instead";
@Override @Override
public FindAndModifyOptions returnNew(boolean returnNew) { public FindAndModifyOptions returnNew(boolean returnNew) {

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

@ -38,7 +38,7 @@ public class FindAndReplaceOptions {
private static final FindAndReplaceOptions NONE = new FindAndReplaceOptions() { private static final FindAndReplaceOptions NONE = new FindAndReplaceOptions() {
private static final String ERROR_MSG = "FindAndReplaceOptions.none() cannot be changed. Please use FindAndReplaceOptions.options() instead."; private static final String ERROR_MSG = "FindAndReplaceOptions.none() cannot be changed; Please use FindAndReplaceOptions.options() instead";
@Override @Override
public FindAndReplaceOptions returnNew() { public FindAndReplaceOptions returnNew() {

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

@ -61,8 +61,8 @@ public interface FindPublisherPreparer extends ReadPreferenceAware {
default FindPublisher<Document> initiateFind(MongoCollection<Document> collection, default FindPublisher<Document> initiateFind(MongoCollection<Document> collection,
Function<MongoCollection<Document>, FindPublisher<Document>> find) { Function<MongoCollection<Document>, FindPublisher<Document>> find) {
Assert.notNull(collection, "Collection must not be null!"); Assert.notNull(collection, "Collection must not be null");
Assert.notNull(find, "Find function must not be null!"); Assert.notNull(find, "Find function must not be null");
if (hasReadPreference()) { if (hasReadPreference()) {
collection = collection.withReadPreference(getReadPreference()); collection = collection.withReadPreference(getReadPreference());

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

@ -39,7 +39,7 @@ class GeoCommandStatistics {
*/ */
private GeoCommandStatistics(Document source) { private GeoCommandStatistics(Document source) {
Assert.notNull(source, "Source document must not be null!"); Assert.notNull(source, "Source document must not be null");
this.source = source; this.source = source;
} }
@ -51,7 +51,7 @@ class GeoCommandStatistics {
*/ */
public static GeoCommandStatistics from(Document commandResult) { public static GeoCommandStatistics from(Document commandResult) {
Assert.notNull(commandResult, "Command result must not be null!"); Assert.notNull(commandResult, "Command result must not be null");
Object stats = commandResult.get("stats"); Object stats = commandResult.get("stats");
return stats == null ? NONE : new GeoCommandStatistics((Document) stats); return stats == null ? NONE : new GeoCommandStatistics((Document) stats);

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

@ -81,7 +81,7 @@ class MappingMongoJsonSchemaCreator implements MongoJsonSchemaCreator {
MappingContext<MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, MappingContext<MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext,
Predicate<JsonSchemaPropertyContext> filter, LinkedMultiValueMap<String, Class<?>> mergeProperties) { Predicate<JsonSchemaPropertyContext> filter, LinkedMultiValueMap<String, Class<?>> mergeProperties) {
Assert.notNull(converter, "Converter must not be null!"); Assert.notNull(converter, "Converter must not be null");
this.converter = converter; this.converter = converter;
this.mappingContext = mappingContext; this.mappingContext = mappingContext;
this.filter = filter; this.filter = filter;

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

@ -57,8 +57,8 @@ public class MongoAction {
public MongoAction(@Nullable WriteConcern defaultWriteConcern, MongoActionOperation mongoActionOperation, public MongoAction(@Nullable WriteConcern defaultWriteConcern, MongoActionOperation mongoActionOperation,
String collectionName, @Nullable Class<?> entityType, @Nullable Document document, @Nullable Document query) { String collectionName, @Nullable Class<?> entityType, @Nullable Document document, @Nullable Document query) {
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(mongoActionOperation, "MongoActionOperation must not be null!"); Assert.notNull(mongoActionOperation, "MongoActionOperation must not be null");
this.defaultWriteConcern = defaultWriteConcern; this.defaultWriteConcern = defaultWriteConcern;
this.mongoActionOperation = mongoActionOperation; this.mongoActionOperation = mongoActionOperation;

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

@ -42,7 +42,7 @@ public class MongoAdmin implements MongoAdminOperations {
*/ */
public MongoAdmin(MongoClient client) { public MongoAdmin(MongoClient client) {
Assert.notNull(client, "Client must not be null!"); Assert.notNull(client, "Client must not be null");
this.mongoClient = client; this.mongoClient = client;
} }

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

@ -146,7 +146,7 @@ public class MongoClientFactoryBean extends AbstractFactoryBean<MongoClient> imp
protected MongoClientSettings computeClientSetting() { protected MongoClientSettings computeClientSetting() {
if (connectionString != null && (StringUtils.hasText(host) || port != null)) { if (connectionString != null && (StringUtils.hasText(host) || port != null)) {
throw new IllegalStateException("ConnectionString and host/port configuration exclude one another!"); throw new IllegalStateException("ConnectionString and host/port configuration exclude one another");
} }
ConnectionString connectionString = this.connectionString != null ? this.connectionString ConnectionString connectionString = this.connectionString != null ? this.connectionString

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

@ -44,8 +44,8 @@ public class MongoDataIntegrityViolationException extends DataIntegrityViolation
super(message); super(message);
Assert.notNull(writeResult, "WriteResult must not be null!"); Assert.notNull(writeResult, "WriteResult must not be null");
Assert.notNull(actionOperation, "MongoActionOperation must not be null!"); Assert.notNull(actionOperation, "MongoActionOperation must not be null");
this.writeResult = writeResult; this.writeResult = writeResult;
this.actionOperation = actionOperation; this.actionOperation = actionOperation;

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

@ -64,10 +64,10 @@ public abstract class MongoDatabaseFactorySupport<C> implements MongoDatabaseFac
protected MongoDatabaseFactorySupport(C mongoClient, String databaseName, boolean mongoInstanceCreated, protected MongoDatabaseFactorySupport(C mongoClient, String databaseName, boolean mongoInstanceCreated,
PersistenceExceptionTranslator exceptionTranslator) { PersistenceExceptionTranslator exceptionTranslator) {
Assert.notNull(mongoClient, "MongoClient must not be null!"); Assert.notNull(mongoClient, "MongoClient must not be null");
Assert.hasText(databaseName, "Database name must not be empty!"); Assert.hasText(databaseName, "Database name must not be empty");
Assert.isTrue(databaseName.matches("[^/\\\\.$\"\\s]+"), Assert.isTrue(databaseName.matches("[^/\\\\.$\"\\s]+"),
"Database name must not contain slashes, dots, spaces, quotes, or dollar signs!"); "Database name must not contain slashes, dots, spaces, quotes, or dollar signs");
this.mongoClient = mongoClient; this.mongoClient = mongoClient;
this.databaseName = databaseName; this.databaseName = databaseName;
@ -91,7 +91,7 @@ public abstract class MongoDatabaseFactorySupport<C> implements MongoDatabaseFac
@Override @Override
public MongoDatabase getMongoDatabase(String dbName) throws DataAccessException { public MongoDatabase getMongoDatabase(String dbName) throws DataAccessException {
Assert.hasText(dbName, "Database name must not be empty!"); Assert.hasText(dbName, "Database name must not be empty");
MongoDatabase db = doGetMongoDatabase(dbName); MongoDatabase db = doGetMongoDatabase(dbName);

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

@ -192,7 +192,7 @@ public interface MongoJsonSchemaCreator {
*/ */
static MongoJsonSchemaCreator create(MongoConverter mongoConverter) { static MongoJsonSchemaCreator create(MongoConverter mongoConverter) {
Assert.notNull(mongoConverter, "MongoConverter must not be null!"); Assert.notNull(mongoConverter, "MongoConverter must not be null");
return new MappingMongoJsonSchemaCreator(mongoConverter); return new MappingMongoJsonSchemaCreator(mongoConverter);
} }

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

@ -178,7 +178,7 @@ public interface MongoOperations extends FluentMongoOperations {
*/ */
default SessionScoped withSession(Supplier<ClientSession> sessionProvider) { default SessionScoped withSession(Supplier<ClientSession> sessionProvider) {
Assert.notNull(sessionProvider, "SessionProvider must not be null!"); Assert.notNull(sessionProvider, "SessionProvider must not be null");
return new SessionScoped() { return new SessionScoped() {
@ -985,7 +985,7 @@ public interface MongoOperations extends FluentMongoOperations {
@Nullable @Nullable
default <T> T findAndReplace(Query query, T replacement, FindAndReplaceOptions options, String collectionName) { default <T> T findAndReplace(Query query, T replacement, FindAndReplaceOptions options, String collectionName) {
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
return findAndReplace(query, replacement, options, (Class<T>) ClassUtils.getUserClass(replacement), collectionName); return findAndReplace(query, replacement, options, (Class<T>) ClassUtils.getUserClass(replacement), collectionName);
} }
@ -1174,7 +1174,7 @@ public interface MongoOperations extends FluentMongoOperations {
*/ */
default long estimatedCount(Class<?> entityClass) { default long estimatedCount(Class<?> entityClass) {
Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(entityClass, "Entity class must not be null");
return estimatedCount(getCollectionName(entityClass)); return estimatedCount(getCollectionName(entityClass));
} }

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

@ -216,7 +216,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
*/ */
public MongoTemplate(MongoDatabaseFactory mongoDbFactory, @Nullable MongoConverter mongoConverter) { public MongoTemplate(MongoDatabaseFactory mongoDbFactory, @Nullable MongoConverter mongoConverter) {
Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!"); Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null");
this.mongoDbFactory = mongoDbFactory; this.mongoDbFactory = mongoDbFactory;
this.exceptionTranslator = mongoDbFactory.getExceptionTranslator(); this.exceptionTranslator = mongoDbFactory.getExceptionTranslator();
@ -338,7 +338,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
*/ */
public void setEntityCallbacks(EntityCallbacks entityCallbacks) { public void setEntityCallbacks(EntityCallbacks entityCallbacks) {
Assert.notNull(entityCallbacks, "EntityCallbacks must not be null!"); Assert.notNull(entityCallbacks, "EntityCallbacks must not be null");
this.entityCallbacks = entityCallbacks; this.entityCallbacks = entityCallbacks;
} }
@ -430,10 +430,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
protected <T> Stream<T> doStream(Query query, Class<?> entityType, String collectionName, Class<T> returnType) { protected <T> Stream<T> doStream(Query query, Class<?> entityType, String collectionName, Class<T> returnType) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(entityType, "Entity type must not be null!"); Assert.notNull(entityType, "Entity type must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(returnType, "ReturnType must not be null!"); Assert.notNull(returnType, "ReturnType must not be null");
return execute(collectionName, (CollectionCallback<Stream<T>>) collection -> { return execute(collectionName, (CollectionCallback<Stream<T>>) collection -> {
@ -462,7 +462,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public Document executeCommand(String jsonCommand) { public Document executeCommand(String jsonCommand) {
Assert.hasText(jsonCommand, "JsonCommand must not be null nor empty!"); Assert.hasText(jsonCommand, "JsonCommand must not be null nor empty");
return execute(db -> db.runCommand(Document.parse(jsonCommand), Document.class)); return execute(db -> db.runCommand(Document.parse(jsonCommand), Document.class));
} }
@ -471,7 +471,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public Document executeCommand(Document command) { public Document executeCommand(Document command) {
Assert.notNull(command, "Command must not be null!"); Assert.notNull(command, "Command must not be null");
return execute(db -> db.runCommand(command, Document.class)); return execute(db -> db.runCommand(command, Document.class));
} }
@ -480,7 +480,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public Document executeCommand(Document command, @Nullable ReadPreference readPreference) { public Document executeCommand(Document command, @Nullable ReadPreference readPreference) {
Assert.notNull(command, "Command must not be null!"); Assert.notNull(command, "Command must not be null");
return execute(db -> readPreference != null // return execute(db -> readPreference != null //
? db.runCommand(command, readPreference, Document.class) // ? db.runCommand(command, readPreference, Document.class) //
@ -506,9 +506,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler documentCallbackHandler, protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler documentCallbackHandler,
@Nullable CursorPreparer preparer) { @Nullable CursorPreparer preparer) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(documentCallbackHandler, "DocumentCallbackHandler must not be null!"); Assert.notNull(documentCallbackHandler, "DocumentCallbackHandler must not be null");
Document queryObject = queryMapper.getMappedObject(query.getQueryObject(), Optional.empty()); Document queryObject = queryMapper.getMappedObject(query.getQueryObject(), Optional.empty());
Document sortObject = query.getSortObject(); Document sortObject = query.getSortObject();
@ -526,7 +526,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T execute(DbCallback<T> action) { public <T> T execute(DbCallback<T> action) {
Assert.notNull(action, "DbCallback must not be null!"); Assert.notNull(action, "DbCallback must not be null");
try { try {
MongoDatabase db = prepareDatabase(this.doGetDatabase()); MongoDatabase db = prepareDatabase(this.doGetDatabase());
@ -539,15 +539,15 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) { public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return execute(getCollectionName(entityClass), callback); return execute(getCollectionName(entityClass), callback);
} }
@Override @Override
public <T> T execute(String collectionName, CollectionCallback<T> callback) { public <T> T execute(String collectionName, CollectionCallback<T> callback) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(callback, "CollectionCallback must not be null!"); Assert.notNull(callback, "CollectionCallback must not be null");
try { try {
MongoCollection<Document> collection = getAndPrepareCollection(doGetDatabase(), collectionName); MongoCollection<Document> collection = getAndPrepareCollection(doGetDatabase(), collectionName);
@ -560,7 +560,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public SessionScoped withSession(ClientSessionOptions options) { public SessionScoped withSession(ClientSessionOptions options) {
Assert.notNull(options, "ClientSessionOptions must not be null!"); Assert.notNull(options, "ClientSessionOptions must not be null");
return withSession(() -> mongoDbFactory.getSession(options)); return withSession(() -> mongoDbFactory.getSession(options));
} }
@ -568,7 +568,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public MongoTemplate withSession(ClientSession session) { public MongoTemplate withSession(ClientSession session) {
Assert.notNull(session, "ClientSession must not be null!"); Assert.notNull(session, "ClientSession must not be null");
return new SessionBoundMongoTemplate(session, MongoTemplate.this); return new SessionBoundMongoTemplate(session, MongoTemplate.this);
} }
@ -593,7 +593,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> MongoCollection<Document> createCollection(Class<T> entityClass, public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
@Nullable CollectionOptions collectionOptions) { @Nullable CollectionOptions collectionOptions) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doCreateCollection(getCollectionName(entityClass), return doCreateCollection(getCollectionName(entityClass),
operations.convertToCreateCollectionOptions(collectionOptions, entityClass)); operations.convertToCreateCollectionOptions(collectionOptions, entityClass));
@ -602,7 +602,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public MongoCollection<Document> createCollection(String collectionName) { public MongoCollection<Document> createCollection(String collectionName) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return doCreateCollection(collectionName, new Document()); return doCreateCollection(collectionName, new Document());
} }
@ -611,7 +611,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public MongoCollection<Document> createCollection(String collectionName, public MongoCollection<Document> createCollection(String collectionName,
@Nullable CollectionOptions collectionOptions) { @Nullable CollectionOptions collectionOptions) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return doCreateCollection(collectionName, return doCreateCollection(collectionName,
operations.convertToCreateCollectionOptions(collectionOptions, Object.class)); operations.convertToCreateCollectionOptions(collectionOptions, Object.class));
} }
@ -620,7 +620,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public MongoCollection<Document> getCollection(String collectionName) { public MongoCollection<Document> getCollection(String collectionName) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return execute(db -> db.getCollection(collectionName, Document.class)); return execute(db -> db.getCollection(collectionName, Document.class));
} }
@ -634,7 +634,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public boolean collectionExists(String collectionName) { public boolean collectionExists(String collectionName) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return execute(db -> { return execute(db -> {
@ -655,7 +655,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public void dropCollection(String collectionName) { public void dropCollection(String collectionName) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
execute(collectionName, (CollectionCallback<Void>) collection -> { execute(collectionName, (CollectionCallback<Void>) collection -> {
collection.drop(); collection.drop();
@ -695,8 +695,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public BulkOperations bulkOps(BulkMode mode, @Nullable Class<?> entityType, String collectionName) { public BulkOperations bulkOps(BulkMode mode, @Nullable Class<?> entityType, String collectionName) {
Assert.notNull(mode, "BulkMode must not be null!"); Assert.notNull(mode, "BulkMode must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
DefaultBulkOperations operations = new DefaultBulkOperations(this, collectionName, DefaultBulkOperations operations = new DefaultBulkOperations(this, collectionName,
new BulkOperationContext(mode, Optional.ofNullable(getPersistentEntity(entityType)), queryMapper, updateMapper, new BulkOperationContext(mode, Optional.ofNullable(getPersistentEntity(entityType)), queryMapper, updateMapper,
@ -724,9 +724,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T findOne(Query query, Class<T> entityClass, String collectionName) { public <T> T findOne(Query query, Class<T> entityClass, String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
if (ObjectUtils.isEmpty(query.getSortObject())) { if (ObjectUtils.isEmpty(query.getSortObject())) {
@ -756,7 +756,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
if (query == null) { if (query == null) {
throw new InvalidDataAccessApiUsageException("Query passed in to exist can't be null"); throw new InvalidDataAccessApiUsageException("Query passed in to exist can't be null");
} }
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
QueryContext queryContext = queryOperations.createQueryContext(query); QueryContext queryContext = queryOperations.createQueryContext(query);
Document mappedQuery = queryContext.getMappedQuery(entityClass, this::getPersistentEntity); Document mappedQuery = queryContext.getMappedQuery(entityClass, this::getPersistentEntity);
@ -775,9 +775,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> List<T> find(Query query, Class<T> entityClass, String collectionName) { public <T> List<T> find(Query query, Class<T> entityClass, String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doFind(collectionName, query.getQueryObject(), query.getFieldsObject(), entityClass, return doFind(collectionName, query.getQueryObject(), query.getFieldsObject(), entityClass,
new QueryCursorPreparer(query, entityClass)); new QueryCursorPreparer(query, entityClass));
@ -793,9 +793,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T findById(Object id, Class<T> entityClass, String collectionName) { public <T> T findById(Object id, Class<T> entityClass, String collectionName) {
Assert.notNull(id, "Id must not be null!"); Assert.notNull(id, "Id must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
String idKey = operations.getIdPropertyName(entityClass); String idKey = operations.getIdPropertyName(entityClass);
@ -812,11 +812,11 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> List<T> findDistinct(Query query, String field, String collectionName, Class<?> entityClass, public <T> List<T> findDistinct(Query query, String field, String collectionName, Class<?> entityClass,
Class<T> resultClass) { Class<T> resultClass) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(resultClass, "ResultClass must not be null!"); Assert.notNull(resultClass, "ResultClass must not be null");
MongoPersistentEntity<?> entity = entityClass != Object.class ? getPersistentEntity(entityClass) : null; MongoPersistentEntity<?> entity = entityClass != Object.class ? getPersistentEntity(entityClass) : null;
DistinctQueryContext distinctQueryContext = queryOperations.distinctQueryContext(query, field); DistinctQueryContext distinctQueryContext = queryOperations.distinctQueryContext(query, field);
@ -872,15 +872,15 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> GeoResults<T> geoNear(NearQuery near, Class<?> domainType, String collectionName, Class<T> returnType) { public <T> GeoResults<T> geoNear(NearQuery near, Class<?> domainType, String collectionName, Class<T> returnType) {
if (near == null) { if (near == null) {
throw new InvalidDataAccessApiUsageException("NearQuery must not be null!"); throw new InvalidDataAccessApiUsageException("NearQuery must not be null");
} }
if (domainType == null) { if (domainType == null) {
throw new InvalidDataAccessApiUsageException("Entity class must not be null!"); throw new InvalidDataAccessApiUsageException("Entity class must not be null");
} }
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(returnType, "ReturnType must not be null!"); Assert.notNull(returnType, "ReturnType must not be null");
String collection = StringUtils.hasText(collectionName) ? collectionName : getCollectionName(domainType); String collection = StringUtils.hasText(collectionName) ? collectionName : getCollectionName(domainType);
String distanceField = operations.nearQueryDistanceFieldName(domainType); String distanceField = operations.nearQueryDistanceFieldName(domainType);
@ -934,17 +934,17 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, Class<T> entityClass, public <T> T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, Class<T> entityClass,
String collectionName) { String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options);
Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); "Both Query and FindAndModifyOptions define a collation; Please provide the collation only via one of the two");
}); });
if (!options.getCollation().isPresent()) { if (!options.getCollation().isPresent()) {
@ -959,15 +959,15 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, public <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType,
String collectionName, Class<T> resultType) { String collectionName, Class<T> resultType) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(options, "Options must not be null Use FindAndReplaceOptions#empty() instead");
Assert.notNull(entityType, "EntityType must not be null!"); Assert.notNull(entityType, "EntityType must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.notNull(resultType, "ResultType must not be null Use Object.class instead");
Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none");
Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip");
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType);
QueryContext queryContext = queryOperations.createQueryContext(query); QueryContext queryContext = queryOperations.createQueryContext(query);
@ -1007,9 +1007,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T findAndRemove(Query query, Class<T> entityClass, String collectionName) { public <T> T findAndRemove(Query query, Class<T> entityClass, String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return doFindAndRemove(collectionName, query.getQueryObject(), query.getFieldsObject(), return doFindAndRemove(collectionName, query.getQueryObject(), query.getFieldsObject(),
getMappedSortObject(query, entityClass), operations.forType(entityClass).getCollation(query).orElse(null), getMappedSortObject(query, entityClass), operations.forType(entityClass).getCollation(query).orElse(null),
@ -1019,7 +1019,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public long count(Query query, Class<?> entityClass) { public long count(Query query, Class<?> entityClass) {
Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(entityClass, "Entity class must not be null");
return count(query, entityClass, getCollectionName(entityClass)); return count(query, entityClass, getCollectionName(entityClass));
} }
@ -1035,8 +1035,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public long count(Query query, @Nullable Class<?> entityClass, String collectionName) { public long count(Query query, @Nullable Class<?> entityClass, String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
CountContext countContext = queryOperations.countQueryContext(query); CountContext countContext = queryOperations.countQueryContext(query);
@ -1103,7 +1103,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T insert(T objectToSave) { public <T> T insert(T objectToSave) {
Assert.notNull(objectToSave, "ObjectToSave must not be null!"); Assert.notNull(objectToSave, "ObjectToSave must not be null");
ensureNotCollectionLike(objectToSave); ensureNotCollectionLike(objectToSave);
return insert(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave))); return insert(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave)));
@ -1113,8 +1113,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T insert(T objectToSave, String collectionName) { public <T> T insert(T objectToSave, String collectionName) {
Assert.notNull(objectToSave, "ObjectToSave must not be null!"); Assert.notNull(objectToSave, "ObjectToSave must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
ensureNotCollectionLike(objectToSave); ensureNotCollectionLike(objectToSave);
return (T) doInsert(collectionName, objectToSave, this.mongoConverter); return (T) doInsert(collectionName, objectToSave, this.mongoConverter);
@ -1130,7 +1130,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected void ensureNotCollectionLike(@Nullable Object source) { protected void ensureNotCollectionLike(@Nullable Object source) {
if (EntityOperations.isCollectionLike(source)) { if (EntityOperations.isCollectionLike(source)) {
throw new IllegalArgumentException("Cannot use a collection here."); throw new IllegalArgumentException("Cannot use a collection here");
} }
} }
@ -1202,7 +1202,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> Collection<T> insert(Collection<? extends T> batchToSave, Class<?> entityClass) { public <T> Collection<T> insert(Collection<? extends T> batchToSave, Class<?> entityClass) {
Assert.notNull(batchToSave, "BatchToSave must not be null!"); Assert.notNull(batchToSave, "BatchToSave must not be null");
return (Collection<T>) doInsertBatch(getCollectionName(entityClass), batchToSave, this.mongoConverter); return (Collection<T>) doInsertBatch(getCollectionName(entityClass), batchToSave, this.mongoConverter);
} }
@ -1211,8 +1211,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> Collection<T> insert(Collection<? extends T> batchToSave, String collectionName) { public <T> Collection<T> insert(Collection<? extends T> batchToSave, String collectionName) {
Assert.notNull(batchToSave, "BatchToSave must not be null!"); Assert.notNull(batchToSave, "BatchToSave must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
return (Collection<T>) doInsertBatch(collectionName, batchToSave, this.mongoConverter); return (Collection<T>) doInsertBatch(collectionName, batchToSave, this.mongoConverter);
} }
@ -1221,7 +1221,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> Collection<T> insertAll(Collection<? extends T> objectsToSave) { public <T> Collection<T> insertAll(Collection<? extends T> objectsToSave) {
Assert.notNull(objectsToSave, "ObjectsToSave must not be null!"); Assert.notNull(objectsToSave, "ObjectsToSave must not be null");
return (Collection<T>) doInsertAll(objectsToSave, this.mongoConverter); return (Collection<T>) doInsertAll(objectsToSave, this.mongoConverter);
} }
@ -1258,7 +1258,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <T> Collection<T> doInsertBatch(String collectionName, Collection<? extends T> batchToSave, protected <T> Collection<T> doInsertBatch(String collectionName, Collection<? extends T> batchToSave,
MongoWriter<T> writer) { MongoWriter<T> writer) {
Assert.notNull(writer, "MongoWriter must not be null!"); Assert.notNull(writer, "MongoWriter must not be null");
List<Document> documentList = new ArrayList<>(); List<Document> documentList = new ArrayList<>();
List<T> initializedBatchToSave = new ArrayList<>(batchToSave.size()); List<T> initializedBatchToSave = new ArrayList<>(batchToSave.size());
@ -1303,7 +1303,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public <T> T save(T objectToSave) { public <T> T save(T objectToSave) {
Assert.notNull(objectToSave, "Object to save must not be null!"); Assert.notNull(objectToSave, "Object to save must not be null");
return save(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave))); return save(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave)));
} }
@ -1311,8 +1311,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T save(T objectToSave, String collectionName) { public <T> T save(T objectToSave, String collectionName) {
Assert.notNull(objectToSave, "Object to save must not be null!"); Assert.notNull(objectToSave, "Object to save must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
ensureNotCollectionLike(objectToSave); ensureNotCollectionLike(objectToSave);
AdaptibleEntity<T> source = operations.forEntity(objectToSave, mongoConverter.getConversionService()); AdaptibleEntity<T> source = operations.forEntity(objectToSave, mongoConverter.getConversionService());
@ -1355,7 +1355,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
if (result.getModifiedCount() == 0) { if (result.getModifiedCount() == 0) {
throw new OptimisticLockingFailureException( throw new OptimisticLockingFailureException(
String.format("Cannot save entity %s with version %s to collection %s. Has it been modified meanwhile?", String.format("Cannot save entity %s with version %s to collection %s; Has it been modified meanwhile",
source.getId(), source.getVersion(), collectionName)); source.getId(), source.getVersion(), collectionName));
} }
maybeEmitEvent(new AfterSaveEvent<>(toSave, mapped.getDocument(), collectionName)); maybeEmitEvent(new AfterSaveEvent<>(toSave, mapped.getDocument(), collectionName));
@ -1492,7 +1492,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public UpdateResult upsert(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) { public UpdateResult upsert(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doUpdate(collectionName, query, update, entityClass, true, false); return doUpdate(collectionName, query, update, entityClass, true, false);
} }
@ -1510,7 +1510,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public UpdateResult updateFirst(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) { public UpdateResult updateFirst(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doUpdate(collectionName, query, update, entityClass, false, false); return doUpdate(collectionName, query, update, entityClass, false, false);
} }
@ -1528,7 +1528,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public UpdateResult updateMulti(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) { public UpdateResult updateMulti(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doUpdate(collectionName, query, update, entityClass, false, true); return doUpdate(collectionName, query, update, entityClass, false, true);
} }
@ -1537,13 +1537,13 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected UpdateResult doUpdate(String collectionName, Query query, UpdateDefinition update, protected UpdateResult doUpdate(String collectionName, Query query, UpdateDefinition update,
@Nullable Class<?> entityClass, boolean upsert, boolean multi) { @Nullable Class<?> entityClass, boolean upsert, boolean multi) {
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
if (query.isSorted() && LOGGER.isWarnEnabled()) { if (query.isSorted() && LOGGER.isWarnEnabled()) {
LOGGER.warn(String.format("%s does not support sort ('%s'). Please use findAndModify() instead.", LOGGER.warn(String.format("%s does not support sort ('%s'); Please use findAndModify() instead",
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject()))); upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject())));
} }
@ -1616,7 +1616,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public DeleteResult remove(Object object) { public DeleteResult remove(Object object) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
return remove(object, getCollectionName(object.getClass())); return remove(object, getCollectionName(object.getClass()));
} }
@ -1624,8 +1624,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public DeleteResult remove(Object object, String collectionName) { public DeleteResult remove(Object object, String collectionName) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Query query = operations.forEntity(object).getRemoveByQuery(); Query query = operations.forEntity(object).getRemoveByQuery();
@ -1645,7 +1645,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override @Override
public DeleteResult remove(Query query, Class<?> entityClass, String collectionName) { public DeleteResult remove(Query query, Class<?> entityClass, String collectionName) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
return doRemove(collectionName, query, entityClass, true); return doRemove(collectionName, query, entityClass, true);
} }
@ -1653,8 +1653,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <T> DeleteResult doRemove(String collectionName, Query query, @Nullable Class<T> entityClass, protected <T> DeleteResult doRemove(String collectionName, Query query, @Nullable Class<T> entityClass,
boolean multi) { boolean multi) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
MongoPersistentEntity<?> entity = getPersistentEntity(entityClass); MongoPersistentEntity<?> entity = getPersistentEntity(entityClass);
@ -1764,11 +1764,11 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> List<T> mapReduce(Query query, Class<?> domainType, String inputCollectionName, String mapFunction, public <T> List<T> mapReduce(Query query, Class<?> domainType, String inputCollectionName, String mapFunction,
String reduceFunction, @Nullable MapReduceOptions mapReduceOptions, Class<T> resultType) { String reduceFunction, @Nullable MapReduceOptions mapReduceOptions, Class<T> resultType) {
Assert.notNull(domainType, "Domain type must not be null!"); Assert.notNull(domainType, "Domain type must not be null");
Assert.notNull(inputCollectionName, "Input collection name must not be null!"); Assert.notNull(inputCollectionName, "Input collection name must not be null");
Assert.notNull(resultType, "Result type must not be null!"); Assert.notNull(resultType, "Result type must not be null");
Assert.notNull(mapFunction, "Map function must not be null!"); Assert.notNull(mapFunction, "Map function must not be null");
Assert.notNull(reduceFunction, "Reduce function must not be null!"); Assert.notNull(reduceFunction, "Reduce function must not be null");
String mapFunc = replaceWithResourceIfNecessary(mapFunction); String mapFunc = replaceWithResourceIfNecessary(mapFunction);
String reduceFunc = replaceWithResourceIfNecessary(reduceFunction); String reduceFunc = replaceWithResourceIfNecessary(reduceFunction);
@ -1798,7 +1798,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
Optionals.ifAllPresent(collation, mapReduceOptions.getCollation(), (l, r) -> { Optionals.ifAllPresent(collation, mapReduceOptions.getCollation(), (l, r) -> {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two."); "Both Query and MapReduceOptions define a collation; Please provide the collation only via one of the two.");
}); });
if (mapReduceOptions.getCollation().isPresent()) { if (mapReduceOptions.getCollation().isPresent()) {
@ -1861,7 +1861,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName,
Class<O> outputType) { Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
return aggregate(aggregation, inputCollectionName, outputType, null); return aggregate(aggregation, inputCollectionName, outputType, null);
} }
@ -1882,7 +1882,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <O> Stream<O> aggregateStream(TypedAggregation<?> aggregation, String inputCollectionName, public <O> Stream<O> aggregateStream(TypedAggregation<?> aggregation, String inputCollectionName,
Class<O> outputType) { Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
AggregationOperationContext context = new TypeBasedAggregationOperationContext(aggregation.getInputType(), AggregationOperationContext context = new TypeBasedAggregationOperationContext(aggregation.getInputType(),
mappingContext, queryMapper); mappingContext, queryMapper);
@ -1949,9 +1949,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <O> AggregationResults<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType, protected <O> AggregationResults<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType,
@Nullable AggregationOperationContext context) { @Nullable AggregationOperationContext context) {
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
Assert.notNull(outputType, "Output type must not be null!"); Assert.notNull(outputType, "Output type must not be null");
return doAggregate(aggregation, collectionName, outputType, return doAggregate(aggregation, collectionName, outputType,
queryOperations.createAggregation(aggregation, context)); queryOperations.createAggregation(aggregation, context));
@ -2043,10 +2043,10 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <O> Stream<O> aggregateStream(Aggregation aggregation, String collectionName, Class<O> outputType, protected <O> Stream<O> aggregateStream(Aggregation aggregation, String collectionName, Class<O> outputType,
@Nullable AggregationOperationContext context) { @Nullable AggregationOperationContext context) {
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
Assert.notNull(outputType, "Output type must not be null!"); Assert.notNull(outputType, "Output type must not be null");
Assert.isTrue(!aggregation.getOptions().isExplain(), "Can't use explain option with streaming!"); Assert.isTrue(!aggregation.getOptions().isExplain(), "Can't use explain option with streaming");
AggregationDefinition aggregationDefinition = queryOperations.createAggregation(aggregation, context); AggregationDefinition aggregationDefinition = queryOperations.createAggregation(aggregation, context);
@ -2123,7 +2123,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
Resource functionResource = resourceLoader.getResource(func); Resource functionResource = resourceLoader.getResource(func);
if (!functionResource.exists()) { if (!functionResource.exists()) {
throw new InvalidDataAccessApiUsageException(String.format("Resource %s not found!", function)); throw new InvalidDataAccessApiUsageException(String.format("Resource %s not found", function));
} }
Scanner scanner = null; Scanner scanner = null;
@ -2132,7 +2132,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
scanner = new Scanner(functionResource.getInputStream()); scanner = new Scanner(functionResource.getInputStream());
return scanner.useDelimiter("\\A").next(); return scanner.useDelimiter("\\A").next();
} catch (IOException e) { } catch (IOException e) {
throw new InvalidDataAccessApiUsageException(String.format("Cannot read map-reduce file %s!", function), e); throw new InvalidDataAccessApiUsageException(String.format("Cannot read map-reduce file %s", function), e);
} finally { } finally {
if (scanner != null) { if (scanner != null) {
scanner.close(); scanner.close();
@ -2809,8 +2809,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public FindCallback(Document query, Document fields, @Nullable com.mongodb.client.model.Collation collation) { public FindCallback(Document query, Document fields, @Nullable com.mongodb.client.model.Collation collation) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
this.query = query; this.query = query;
this.fields = fields; this.fields = fields;
@ -3197,7 +3197,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
*/ */
GeoNearResultDocumentCallback(String distanceField, DocumentCallback<T> delegate, Metric metric) { GeoNearResultDocumentCallback(String distanceField, DocumentCallback<T> delegate, Metric metric) {
Assert.notNull(delegate, "DocumentCallback must not be null!"); Assert.notNull(delegate, "DocumentCallback must not be null");
this.distanceField = distanceField; this.distanceField = distanceField;
this.delegate = delegate; this.delegate = delegate;

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

@ -41,7 +41,7 @@ class ReactiveAggregationOperationSupport implements ReactiveAggregationOperatio
*/ */
ReactiveAggregationOperationSupport(ReactiveMongoTemplate template) { ReactiveAggregationOperationSupport(ReactiveMongoTemplate template) {
Assert.notNull(template, "Template must not be null!"); Assert.notNull(template, "Template must not be null");
this.template = template; this.template = template;
} }
@ -49,7 +49,7 @@ class ReactiveAggregationOperationSupport implements ReactiveAggregationOperatio
@Override @Override
public <T> ReactiveAggregation<T> aggregateAndReturn(Class<T> domainType) { public <T> ReactiveAggregation<T> aggregateAndReturn(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveAggregationSupport<>(template, domainType, null, null); return new ReactiveAggregationSupport<>(template, domainType, null, null);
} }
@ -74,7 +74,7 @@ class ReactiveAggregationOperationSupport implements ReactiveAggregationOperatio
@Override @Override
public AggregationOperationWithAggregation<T> inCollection(String collection) { public AggregationOperationWithAggregation<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ReactiveAggregationSupport<>(template, domainType, aggregation, collection); return new ReactiveAggregationSupport<>(template, domainType, aggregation, collection);
} }
@ -82,7 +82,7 @@ class ReactiveAggregationOperationSupport implements ReactiveAggregationOperatio
@Override @Override
public TerminatingAggregationOperation<T> by(Aggregation aggregation) { public TerminatingAggregationOperation<T> by(Aggregation aggregation) {
Assert.notNull(aggregation, "Aggregation must not be null!"); Assert.notNull(aggregation, "Aggregation must not be null");
return new ReactiveAggregationSupport<>(template, domainType, aggregation, collection); return new ReactiveAggregationSupport<>(template, domainType, aggregation, collection);
} }

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

@ -49,7 +49,7 @@ class ReactiveChangeStreamOperationSupport implements ReactiveChangeStreamOperat
@Override @Override
public <T> ReactiveChangeStream<T> changeStream(Class<T> domainType) { public <T> ReactiveChangeStream<T> changeStream(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveChangeStreamSupport<>(template, domainType, domainType, null, null); return new ReactiveChangeStreamSupport<>(template, domainType, domainType, null, null);
} }
@ -75,7 +75,7 @@ class ReactiveChangeStreamOperationSupport implements ReactiveChangeStreamOperat
@Override @Override
public ChangeStreamWithFilterAndProjection<T> watchCollection(String collection) { public ChangeStreamWithFilterAndProjection<T> watchCollection(String collection) {
Assert.hasText(collection, "Collection name must not be null nor empty!"); Assert.hasText(collection, "Collection name must not be null nor empty");
return new ReactiveChangeStreamSupport<>(template, domainType, returnType, collection, options); return new ReactiveChangeStreamSupport<>(template, domainType, returnType, collection, options);
} }
@ -83,7 +83,7 @@ class ReactiveChangeStreamOperationSupport implements ReactiveChangeStreamOperat
@Override @Override
public ChangeStreamWithFilterAndProjection<T> watchCollection(Class<?> entityClass) { public ChangeStreamWithFilterAndProjection<T> watchCollection(Class<?> entityClass) {
Assert.notNull(entityClass, "Collection type not be null!"); Assert.notNull(entityClass, "Collection type not be null");
return watchCollection(template.getCollectionName(entityClass)); return watchCollection(template.getCollectionName(entityClass));
} }
@ -129,7 +129,7 @@ class ReactiveChangeStreamOperationSupport implements ReactiveChangeStreamOperat
@Override @Override
public <R> ChangeStreamWithFilterAndProjection<R> as(Class<R> resultType) { public <R> ChangeStreamWithFilterAndProjection<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new ReactiveChangeStreamSupport<>(template, domainType, resultType, collection, options); return new ReactiveChangeStreamSupport<>(template, domainType, resultType, collection, options);
} }

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

@ -47,7 +47,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public <T> ReactiveFind<T> query(Class<T> domainType) { public <T> ReactiveFind<T> query(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveFindSupport<>(template, domainType, domainType, null, ALL_QUERY); return new ReactiveFindSupport<>(template, domainType, domainType, null, ALL_QUERY);
} }
@ -80,7 +80,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public FindWithProjection<T> inCollection(String collection) { public FindWithProjection<T> inCollection(String collection) {
Assert.hasText(collection, "Collection name must not be null nor empty!"); Assert.hasText(collection, "Collection name must not be null nor empty");
return new ReactiveFindSupport<>(template, domainType, returnType, collection, query); return new ReactiveFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -88,7 +88,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public <T1> FindWithQuery<T1> as(Class<T1> returnType) { public <T1> FindWithQuery<T1> as(Class<T1> returnType) {
Assert.notNull(returnType, "ReturnType must not be null!"); Assert.notNull(returnType, "ReturnType must not be null");
return new ReactiveFindSupport<>(template, domainType, returnType, collection, query); return new ReactiveFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -96,7 +96,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public TerminatingFind<T> matching(Query query) { public TerminatingFind<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ReactiveFindSupport<>(template, domainType, returnType, collection, query); return new ReactiveFindSupport<>(template, domainType, returnType, collection, query);
} }
@ -124,7 +124,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
if (it.size() > 1) { if (it.size() > 1) {
return Mono.error( return Mono.error(
new IncorrectResultSizeDataAccessException("Query " + asString() + " returned non unique result.", 1)); new IncorrectResultSizeDataAccessException("Query " + asString() + " returned non unique result", 1));
} }
return Mono.just(it.get(0)); return Mono.just(it.get(0));
@ -159,7 +159,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public TerminatingDistinct<Object> distinct(String field) { public TerminatingDistinct<Object> distinct(String field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
return new DistinctOperationSupport<>(this, field); return new DistinctOperationSupport<>(this, field);
} }
@ -210,7 +210,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@Override @Override
public <R> TerminatingDistinct<R> as(Class<R> resultType) { public <R> TerminatingDistinct<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new DistinctOperationSupport<>((ReactiveFindSupport) delegate.as(resultType), field); return new DistinctOperationSupport<>((ReactiveFindSupport) delegate.as(resultType), field);
} }
@ -219,7 +219,7 @@ class ReactiveFindOperationSupport implements ReactiveFindOperation {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TerminatingDistinct<T> matching(Query query) { public TerminatingDistinct<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new DistinctOperationSupport<>((ReactiveFindSupport<T>) delegate.matching(query), field); return new DistinctOperationSupport<>((ReactiveFindSupport<T>) delegate.matching(query), field);
} }

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

@ -41,7 +41,7 @@ class ReactiveInsertOperationSupport implements ReactiveInsertOperation {
@Override @Override
public <T> ReactiveInsert<T> insert(Class<T> domainType) { public <T> ReactiveInsert<T> insert(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveInsertSupport<>(template, domainType, null); return new ReactiveInsertSupport<>(template, domainType, null);
} }
@ -62,7 +62,7 @@ class ReactiveInsertOperationSupport implements ReactiveInsertOperation {
@Override @Override
public Mono<T> one(T object) { public Mono<T> one(T object) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
return template.insert(object, getCollectionName()); return template.insert(object, getCollectionName());
} }
@ -70,7 +70,7 @@ class ReactiveInsertOperationSupport implements ReactiveInsertOperation {
@Override @Override
public Flux<T> all(Collection<? extends T> objects) { public Flux<T> all(Collection<? extends T> objects) {
Assert.notNull(objects, "Objects must not be null!"); Assert.notNull(objects, "Objects must not be null");
return template.insert(objects, getCollectionName()); return template.insert(objects, getCollectionName());
} }
@ -78,7 +78,7 @@ class ReactiveInsertOperationSupport implements ReactiveInsertOperation {
@Override @Override
public ReactiveInsert<T> inCollection(String collection) { public ReactiveInsert<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty."); Assert.hasText(collection, "Collection must not be null nor empty");
return new ReactiveInsertSupport<>(template, domainType, collection); return new ReactiveInsertSupport<>(template, domainType, collection);
} }

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

@ -46,7 +46,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public <T> ReactiveMapReduceSupport<T> mapReduce(Class<T> domainType) { public <T> ReactiveMapReduceSupport<T> mapReduce(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveMapReduceSupport<>(template, domainType, domainType, null, ALL_QUERY, null, null, null); return new ReactiveMapReduceSupport<>(template, domainType, domainType, null, ALL_QUERY, null, null, null);
} }
@ -100,7 +100,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public MapReduceWithProjection<T> inCollection(String collection) { public MapReduceWithProjection<T> inCollection(String collection) {
Assert.hasText(collection, "Collection name must not be null nor empty!"); Assert.hasText(collection, "Collection name must not be null nor empty");
return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -113,7 +113,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public TerminatingMapReduce<T> matching(Query query) { public TerminatingMapReduce<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -126,7 +126,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public <R> MapReduceWithQuery<R> as(Class<R> resultType) { public <R> MapReduceWithQuery<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new ReactiveMapReduceSupport<>(template, domainType, resultType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, resultType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -139,7 +139,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public ReactiveMapReduce<T> with(MapReduceOptions options) { public ReactiveMapReduce<T> with(MapReduceOptions options) {
Assert.notNull(options, "Options must not be null! Please consider empty MapReduceOptions#options() instead."); Assert.notNull(options, "Options must not be null Please consider empty MapReduceOptions#options() instead");
return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -152,7 +152,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public MapReduceWithReduceFunction<T> map(String mapFunction) { public MapReduceWithReduceFunction<T> map(String mapFunction) {
Assert.hasText(mapFunction, "MapFunction name must not be null nor empty!"); Assert.hasText(mapFunction, "MapFunction name must not be null nor empty");
return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);
@ -165,7 +165,7 @@ class ReactiveMapReduceOperationSupport implements ReactiveMapReduceOperation {
@Override @Override
public ReactiveMapReduce<T> reduce(String reduceFunction) { public ReactiveMapReduce<T> reduce(String reduceFunction) {
Assert.hasText(reduceFunction, "ReduceFunction name must not be null nor empty!"); Assert.hasText(reduceFunction, "ReduceFunction name must not be null nor empty");
return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction, return new ReactiveMapReduceSupport<>(template, domainType, returnType, collection, query, mapFunction,
reduceFunction, options); reduceFunction, options);

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

@ -115,7 +115,7 @@ public class ReactiveMongoClientFactoryBean extends AbstractFactoryBean<MongoCli
} }
throw new IllegalStateException( throw new IllegalStateException(
"Cannot create MongoClients. One of the following is required: mongoClientSettings, connectionString or host/port"); "Cannot create MongoClients; One of the following is required: mongoClientSettings, connectionString or host/port");
} }
@Override @Override

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

@ -70,8 +70,8 @@ public class ReactiveMongoContext {
*/ */
public static Context setSession(Context context, Publisher<ClientSession> session) { public static Context setSession(Context context, Publisher<ClientSession> session) {
Assert.notNull(context, "Context must not be null!"); Assert.notNull(context, "Context must not be null");
Assert.notNull(session, "Session publisher must not be null!"); Assert.notNull(session, "Session publisher must not be null");
return context.put(SESSION_KEY, Mono.from(session)); return context.put(SESSION_KEY, Mono.from(session));
} }

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

@ -164,7 +164,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
*/ */
default ReactiveSessionScoped withSession(Supplier<ClientSession> sessionProvider) { default ReactiveSessionScoped withSession(Supplier<ClientSession> sessionProvider) {
Assert.notNull(sessionProvider, "SessionProvider must not be null!"); Assert.notNull(sessionProvider, "SessionProvider must not be null");
return withSession(Mono.fromSupplier(sessionProvider)); return withSession(Mono.fromSupplier(sessionProvider));
} }
@ -756,7 +756,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
*/ */
default <T> Mono<T> findAndReplace(Query query, T replacement, FindAndReplaceOptions options, String collectionName) { default <T> Mono<T> findAndReplace(Query query, T replacement, FindAndReplaceOptions options, String collectionName) {
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
return findAndReplace(query, replacement, options, (Class<T>) ClassUtils.getUserClass(replacement), collectionName); return findAndReplace(query, replacement, options, (Class<T>) ClassUtils.getUserClass(replacement), collectionName);
} }
@ -941,7 +941,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
*/ */
default Mono<Long> estimatedCount(Class<?> entityClass) { default Mono<Long> estimatedCount(Class<?> entityClass) {
Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(entityClass, "Entity class must not be null");
return estimatedCount(getCollectionName(entityClass)); return estimatedCount(getCollectionName(entityClass));
} }

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

@ -241,7 +241,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory, public ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory,
@Nullable MongoConverter mongoConverter, Consumer<Throwable> subscriptionExceptionHandler) { @Nullable MongoConverter mongoConverter, Consumer<Throwable> subscriptionExceptionHandler) {
Assert.notNull(mongoDatabaseFactory, "ReactiveMongoDatabaseFactory must not be null!"); Assert.notNull(mongoDatabaseFactory, "ReactiveMongoDatabaseFactory must not be null");
this.mongoDatabaseFactory = mongoDatabaseFactory; this.mongoDatabaseFactory = mongoDatabaseFactory;
this.exceptionTranslator = mongoDatabaseFactory.getExceptionTranslator(); this.exceptionTranslator = mongoDatabaseFactory.getExceptionTranslator();
@ -367,7 +367,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public void setEntityCallbacks(ReactiveEntityCallbacks entityCallbacks) { public void setEntityCallbacks(ReactiveEntityCallbacks entityCallbacks) {
Assert.notNull(entityCallbacks, "EntityCallbacks must not be null!"); Assert.notNull(entityCallbacks, "EntityCallbacks must not be null");
this.entityCallbacks = entityCallbacks; this.entityCallbacks = entityCallbacks;
} }
@ -468,7 +468,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<Document> executeCommand(String jsonCommand) { public Mono<Document> executeCommand(String jsonCommand) {
Assert.notNull(jsonCommand, "Command must not be empty!"); Assert.notNull(jsonCommand, "Command must not be empty");
return executeCommand(Document.parse(jsonCommand)); return executeCommand(Document.parse(jsonCommand));
} }
@ -481,7 +481,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<Document> executeCommand(Document command, @Nullable ReadPreference readPreference) { public Mono<Document> executeCommand(Document command, @Nullable ReadPreference readPreference) {
Assert.notNull(command, "Command must not be null!"); Assert.notNull(command, "Command must not be null");
return createFlux(db -> readPreference != null ? db.runCommand(command, readPreference, Document.class) return createFlux(db -> readPreference != null ? db.runCommand(command, readPreference, Document.class)
: db.runCommand(command, Document.class)).next(); : db.runCommand(command, Document.class)).next();
@ -500,7 +500,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.notNull(callback, "ReactiveCollectionCallback must not be null!"); Assert.notNull(callback, "ReactiveCollectionCallback must not be null");
return createFlux(collectionName, callback); return createFlux(collectionName, callback);
} }
@ -565,7 +565,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Flux<T> createFlux(ReactiveDatabaseCallback<T> callback) { public <T> Flux<T> createFlux(ReactiveDatabaseCallback<T> callback) {
Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!"); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null");
return Mono.defer(this::doGetDatabase).flatMapMany(database -> callback.doInDB(prepareDatabase(database))) return Mono.defer(this::doGetDatabase).flatMapMany(database -> callback.doInDB(prepareDatabase(database)))
.onErrorMap(translateException()); .onErrorMap(translateException());
@ -580,7 +580,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> createMono(ReactiveDatabaseCallback<T> callback) { public <T> Mono<T> createMono(ReactiveDatabaseCallback<T> callback) {
Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!"); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null");
return Mono.defer(this::doGetDatabase).flatMap(database -> Mono.from(callback.doInDB(prepareDatabase(database)))) return Mono.defer(this::doGetDatabase).flatMap(database -> Mono.from(callback.doInDB(prepareDatabase(database))))
.onErrorMap(translateException()); .onErrorMap(translateException());
@ -595,8 +595,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!"); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null");
Mono<MongoCollection<Document>> collectionPublisher = doGetDatabase() Mono<MongoCollection<Document>> collectionPublisher = doGetDatabase()
.map(database -> getAndPrepareCollection(database, collectionName)); .map(database -> getAndPrepareCollection(database, collectionName));
@ -614,8 +614,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> createMono(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Mono<T> createMono(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(callback, "ReactiveCollectionCallback must not be null!"); Assert.notNull(callback, "ReactiveCollectionCallback must not be null");
Mono<MongoCollection<Document>> collectionPublisher = doGetDatabase() Mono<MongoCollection<Document>> collectionPublisher = doGetDatabase()
.map(database -> getAndPrepareCollection(database, collectionName)); .map(database -> getAndPrepareCollection(database, collectionName));
@ -633,7 +633,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public <T> Mono<MongoCollection<Document>> createCollection(Class<T> entityClass, public <T> Mono<MongoCollection<Document>> createCollection(Class<T> entityClass,
@Nullable CollectionOptions collectionOptions) { @Nullable CollectionOptions collectionOptions) {
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
CollectionOptions options = collectionOptions != null ? collectionOptions : CollectionOptions.empty(); CollectionOptions options = collectionOptions != null ? collectionOptions : CollectionOptions.empty();
options = Optionals options = Optionals
@ -658,7 +658,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<MongoCollection<Document>> getCollection(String collectionName) { public Mono<MongoCollection<Document>> getCollection(String collectionName) {
Assert.notNull(collectionName, "Collection name must not be null!"); Assert.notNull(collectionName, "Collection name must not be null");
return createMono(db -> Mono.just(db.getCollection(collectionName))); return createMono(db -> Mono.just(db.getCollection(collectionName)));
} }
@ -795,11 +795,11 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public <T> Flux<T> findDistinct(Query query, String field, String collectionName, Class<?> entityClass, public <T> Flux<T> findDistinct(Query query, String field, String collectionName, Class<?> entityClass,
Class<T> resultClass) { Class<T> resultClass) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null");
Assert.notNull(resultClass, "ResultClass must not be null!"); Assert.notNull(resultClass, "ResultClass must not be null");
MongoPersistentEntity<?> entity = getPersistentEntity(entityClass); MongoPersistentEntity<?> entity = getPersistentEntity(entityClass);
DistinctQueryContext distinctQueryContext = queryOperations.distinctQueryContext(query, field); DistinctQueryContext distinctQueryContext = queryOperations.distinctQueryContext(query, field);
@ -839,7 +839,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <O> Flux<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType) { public <O> Flux<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
return doAggregate(aggregation, inputCollectionName, aggregation.getInputType(), outputType); return doAggregate(aggregation, inputCollectionName, aggregation.getInputType(), outputType);
} }
@ -862,12 +862,12 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
protected <O> Flux<O> doAggregate(Aggregation aggregation, String collectionName, @Nullable Class<?> inputType, protected <O> Flux<O> doAggregate(Aggregation aggregation, String collectionName, @Nullable Class<?> inputType,
Class<O> outputType) { Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!"); Assert.notNull(aggregation, "Aggregation pipeline must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
Assert.notNull(outputType, "Output type must not be null!"); Assert.notNull(outputType, "Output type must not be null");
AggregationOptions options = aggregation.getOptions(); AggregationOptions options = aggregation.getOptions();
Assert.isTrue(!options.isExplain(), "Cannot use explain option with streaming!"); Assert.isTrue(!options.isExplain(), "Cannot use explain option with streaming");
AggregationDefinition ctx = queryOperations.createAggregation(aggregation, inputType); AggregationDefinition ctx = queryOperations.createAggregation(aggregation, inputType);
@ -925,11 +925,11 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
Class<T> returnType) { Class<T> returnType) {
if (near == null) { if (near == null) {
throw new InvalidDataAccessApiUsageException("NearQuery must not be null!"); throw new InvalidDataAccessApiUsageException("NearQuery must not be null");
} }
if (entityClass == null) { if (entityClass == null) {
throw new InvalidDataAccessApiUsageException("Entity class must not be null!"); throw new InvalidDataAccessApiUsageException("Entity class must not be null");
} }
String collection = StringUtils.hasText(collectionName) ? collectionName : getCollectionName(entityClass); String collection = StringUtils.hasText(collectionName) ? collectionName : getCollectionName(entityClass);
@ -966,14 +966,14 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public <T> Mono<T> findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, public <T> Mono<T> findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options,
Class<T> entityClass, String collectionName) { Class<T> entityClass, String collectionName) {
Assert.notNull(options, "Options must not be null! "); Assert.notNull(options, "Options must not be null ");
Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(entityClass, "Entity class must not be null");
FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options);
Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); "Both Query and FindAndModifyOptions define a collation; Please provide the collation only via one of the two");
}); });
if (!optionsToUse.getCollation().isPresent()) { if (!optionsToUse.getCollation().isPresent()) {
@ -988,15 +988,15 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public <S, T> Mono<T> findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, public <S, T> Mono<T> findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType,
String collectionName, Class<T> resultType) { String collectionName, Class<T> resultType) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
Assert.notNull(options, "Options must not be null! Use FindAndReplaceOptions#empty() instead."); Assert.notNull(options, "Options must not be null Use FindAndReplaceOptions#empty() instead");
Assert.notNull(entityType, "Entity class must not be null!"); Assert.notNull(entityType, "Entity class must not be null");
Assert.notNull(collectionName, "CollectionName must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null");
Assert.notNull(resultType, "ResultType must not be null! Use Object.class instead."); Assert.notNull(resultType, "ResultType must not be null Use Object.class instead");
Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none!"); Assert.isTrue(query.getLimit() <= 1, "Query must not define a limit other than 1 ore none");
Assert.isTrue(query.getSkip() <= 0, "Query must not define skip."); Assert.isTrue(query.getSkip() <= 0, "Query must not define skip");
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType); MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityType);
QueryContext queryContext = queryOperations.createQueryContext(query); QueryContext queryContext = queryOperations.createQueryContext(query);
@ -1053,7 +1053,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<Long> count(Query query, Class<?> entityClass) { public Mono<Long> count(Query query, Class<?> entityClass) {
Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(entityClass, "Entity class must not be null");
return count(query, entityClass, getCollectionName(entityClass)); return count(query, entityClass, getCollectionName(entityClass));
} }
@ -1066,8 +1066,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String collectionName) { public Mono<Long> count(Query query, @Nullable Class<?> entityClass, String collectionName) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
return createMono(collectionName, collection -> { return createMono(collectionName, collection -> {
@ -1152,7 +1152,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> insert(Mono<? extends T> objectToSave) { public <T> Mono<T> insert(Mono<? extends T> objectToSave) {
Assert.notNull(objectToSave, "Mono to insert must not be null!"); Assert.notNull(objectToSave, "Mono to insert must not be null");
return objectToSave.flatMap(this::insert); return objectToSave.flatMap(this::insert);
} }
@ -1165,7 +1165,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Flux<T> insertAll(Mono<? extends Collection<? extends T>> batchToSave, String collectionName) { public <T> Flux<T> insertAll(Mono<? extends Collection<? extends T>> batchToSave, String collectionName) {
Assert.notNull(batchToSave, "Batch to insert must not be null!"); Assert.notNull(batchToSave, "Batch to insert must not be null");
return Flux.from(batchToSave).flatMap(collection -> insert(collection, collectionName)); return Flux.from(batchToSave).flatMap(collection -> insert(collection, collectionName));
} }
@ -1173,7 +1173,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> insert(T objectToSave) { public <T> Mono<T> insert(T objectToSave) {
Assert.notNull(objectToSave, "Object to insert must not be null!"); Assert.notNull(objectToSave, "Object to insert must not be null");
ensureNotCollectionLike(objectToSave); ensureNotCollectionLike(objectToSave);
return insert(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave))); return insert(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave)));
@ -1182,7 +1182,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> insert(T objectToSave, String collectionName) { public <T> Mono<T> insert(T objectToSave, String collectionName) {
Assert.notNull(objectToSave, "Object to insert must not be null!"); Assert.notNull(objectToSave, "Object to insert must not be null");
ensureNotCollectionLike(objectToSave); ensureNotCollectionLike(objectToSave);
return doInsert(collectionName, objectToSave, this.mongoConverter); return doInsert(collectionName, objectToSave, this.mongoConverter);
@ -1257,7 +1257,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
protected <T> Flux<T> doInsertBatch(String collectionName, Collection<? extends T> batchToSave, protected <T> Flux<T> doInsertBatch(String collectionName, Collection<? extends T> batchToSave,
MongoWriter<Object> writer) { MongoWriter<Object> writer) {
Assert.notNull(writer, "MongoWriter must not be null!"); Assert.notNull(writer, "MongoWriter must not be null");
Mono<List<Tuple2<AdaptibleEntity<T>, Document>>> prepareDocuments = Flux.fromIterable(batchToSave) Mono<List<Tuple2<AdaptibleEntity<T>, Document>>> prepareDocuments = Flux.fromIterable(batchToSave)
.flatMap(uninitialized -> { .flatMap(uninitialized -> {
@ -1300,7 +1300,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> save(Mono<? extends T> objectToSave) { public <T> Mono<T> save(Mono<? extends T> objectToSave) {
Assert.notNull(objectToSave, "Mono to save must not be null!"); Assert.notNull(objectToSave, "Mono to save must not be null");
return objectToSave.flatMap(this::save); return objectToSave.flatMap(this::save);
} }
@ -1308,7 +1308,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> save(Mono<? extends T> objectToSave, String collectionName) { public <T> Mono<T> save(Mono<? extends T> objectToSave, String collectionName) {
Assert.notNull(objectToSave, "Mono to save must not be null!"); Assert.notNull(objectToSave, "Mono to save must not be null");
return objectToSave.flatMap(o -> save(o, collectionName)); return objectToSave.flatMap(o -> save(o, collectionName));
} }
@ -1316,15 +1316,15 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public <T> Mono<T> save(T objectToSave) { public <T> Mono<T> save(T objectToSave) {
Assert.notNull(objectToSave, "Object to save must not be null!"); Assert.notNull(objectToSave, "Object to save must not be null");
return save(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave))); return save(objectToSave, getCollectionName(ClassUtils.getUserClass(objectToSave)));
} }
@Override @Override
public <T> Mono<T> save(T objectToSave, String collectionName) { public <T> Mono<T> save(T objectToSave, String collectionName) {
Assert.notNull(objectToSave, "Object to save must not be null!"); Assert.notNull(objectToSave, "Object to save must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
AdaptibleEntity<T> source = operations.forEntity(objectToSave, mongoConverter.getConversionService()); AdaptibleEntity<T> source = operations.forEntity(objectToSave, mongoConverter.getConversionService());
@ -1568,7 +1568,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
if (query.isSorted() && LOGGER.isWarnEnabled()) { if (query.isSorted() && LOGGER.isWarnEnabled()) {
LOGGER.warn(String.format("%s does not support sort ('%s'). Please use findAndModify() instead.", LOGGER.warn(String.format("%s does not support sort ('%s'); Please use findAndModify() instead",
upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject()))); upsert ? "Upsert" : "UpdateFirst", serializeToJsonSafely(query.getSortObject())));
} }
@ -1682,7 +1682,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<DeleteResult> remove(Object object) { public Mono<DeleteResult> remove(Object object) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
return remove(operations.forEntity(object).getRemoveByQuery(), object.getClass()); return remove(operations.forEntity(object).getRemoveByQuery(), object.getClass());
} }
@ -1690,8 +1690,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override @Override
public Mono<DeleteResult> remove(Object object, String collectionName) { public Mono<DeleteResult> remove(Object object, String collectionName) {
Assert.notNull(object, "Object must not be null!"); Assert.notNull(object, "Object must not be null");
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
return doRemove(collectionName, operations.forEntity(object).getRemoveByQuery(), object.getClass()); return doRemove(collectionName, operations.forEntity(object).getRemoveByQuery(), object.getClass());
} }
@ -1711,7 +1711,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
if (!MongoSimpleTypes.AUTOGENERATED_ID_TYPES.contains(property.getType())) { if (!MongoSimpleTypes.AUTOGENERATED_ID_TYPES.contains(property.getType())) {
throw new InvalidDataAccessApiUsageException( throw new InvalidDataAccessApiUsageException(
String.format("Cannot autogenerate id of type %s for entity of type %s!", property.getType().getName(), String.format("Cannot autogenerate id of type %s for entity of type %s", property.getType().getName(),
value.getClass().getName())); value.getClass().getName()));
} }
} }
@ -1735,10 +1735,10 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
protected <T> Mono<DeleteResult> doRemove(String collectionName, Query query, @Nullable Class<T> entityClass) { protected <T> Mono<DeleteResult> doRemove(String collectionName, Query query, @Nullable Class<T> entityClass) {
if (query == null) { if (query == null) {
throw new InvalidDataAccessApiUsageException("Query passed in to remove can't be null!"); throw new InvalidDataAccessApiUsageException("Query passed in to remove can't be null");
} }
Assert.hasText(collectionName, "Collection name must not be null or empty!"); Assert.hasText(collectionName, "Collection name must not be null or empty");
MongoPersistentEntity<?> entity = getPersistentEntity(entityClass); MongoPersistentEntity<?> entity = getPersistentEntity(entityClass);
@ -1895,13 +1895,13 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public <T> Flux<T> mapReduce(Query filterQuery, Class<?> domainType, String inputCollectionName, Class<T> resultType, public <T> Flux<T> mapReduce(Query filterQuery, Class<?> domainType, String inputCollectionName, Class<T> resultType,
String mapFunction, String reduceFunction, MapReduceOptions options) { String mapFunction, String reduceFunction, MapReduceOptions options) {
Assert.notNull(filterQuery, "Filter query must not be null!"); Assert.notNull(filterQuery, "Filter query must not be null");
Assert.notNull(domainType, "Domain type must not be null!"); Assert.notNull(domainType, "Domain type must not be null");
Assert.hasText(inputCollectionName, "Input collection name must not be null or empty!"); Assert.hasText(inputCollectionName, "Input collection name must not be null or empty");
Assert.notNull(resultType, "Result type must not be null!"); Assert.notNull(resultType, "Result type must not be null");
Assert.notNull(mapFunction, "Map function must not be null!"); Assert.notNull(mapFunction, "Map function must not be null");
Assert.notNull(reduceFunction, "Reduce function must not be null!"); Assert.notNull(reduceFunction, "Reduce function must not be null");
Assert.notNull(options, "MapReduceOptions must not be null!"); Assert.notNull(options, "MapReduceOptions must not be null");
assertLocalFunctionNames(mapFunction, reduceFunction); assertLocalFunctionNames(mapFunction, reduceFunction);
@ -1927,7 +1927,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
if (filterQuery.getLimit() > 0 && (options.getLimit() != null)) { if (filterQuery.getLimit() > 0 && (options.getLimit() != null)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Both Query and MapReduceOptions define a limit. Please provide the limit only via one of the two."); "Both Query and MapReduceOptions define a limit; Please provide the limit only via one of the two.");
} }
if (filterQuery.getLimit() > 0) { if (filterQuery.getLimit() > 0) {
@ -1943,7 +1943,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
Optionals.ifAllPresent(filterQuery.getCollation(), options.getCollation(), (l, r) -> { Optionals.ifAllPresent(filterQuery.getCollation(), options.getCollation(), (l, r) -> {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two."); "Both Query and MapReduceOptions define a collation; Please provide the collation only via one of the two.");
}); });
if (options.getCollation().isPresent()) { if (options.getCollation().isPresent()) {
@ -1992,7 +1992,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
if (ResourceUtils.isUrl(function)) { if (ResourceUtils.isUrl(function)) {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"Blocking accessing to resource %s is not allowed using reactive infrastructure. You may load the resource at startup and cache its value.", "Blocking accessing to resource %s is not allowed using reactive infrastructure; You may load the resource at startup and cache its value.",
function)); function));
} }
} }
@ -2850,8 +2850,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) { ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) {
Assert.notNull(reader, "EntityReader must not be null!"); Assert.notNull(reader, "EntityReader must not be null");
Assert.notNull(type, "Entity type must not be null!"); Assert.notNull(type, "Entity type must not be null");
this.reader = reader; this.reader = reader;
this.type = type; this.type = type;
@ -2939,7 +2939,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
GeoNearResultDocumentCallback(String distanceField, DocumentCallback<T> delegate, Metric metric) { GeoNearResultDocumentCallback(String distanceField, DocumentCallback<T> delegate, Metric metric) {
Assert.notNull(delegate, "DocumentCallback must not be null!"); Assert.notNull(delegate, "DocumentCallback must not be null");
this.distanceField = distanceField; this.distanceField = distanceField;
this.delegate = delegate; this.delegate = delegate;

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

@ -44,7 +44,7 @@ class ReactiveRemoveOperationSupport implements ReactiveRemoveOperation {
@Override @Override
public <T> ReactiveRemove<T> remove(Class<T> domainType) { public <T> ReactiveRemove<T> remove(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveRemoveSupport<>(tempate, domainType, ALL_QUERY, null); return new ReactiveRemoveSupport<>(tempate, domainType, ALL_QUERY, null);
} }
@ -67,7 +67,7 @@ class ReactiveRemoveOperationSupport implements ReactiveRemoveOperation {
@Override @Override
public RemoveWithQuery<T> inCollection(String collection) { public RemoveWithQuery<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ReactiveRemoveSupport<>(template, domainType, query, collection); return new ReactiveRemoveSupport<>(template, domainType, query, collection);
} }
@ -75,7 +75,7 @@ class ReactiveRemoveOperationSupport implements ReactiveRemoveOperation {
@Override @Override
public TerminatingRemove<T> matching(Query query) { public TerminatingRemove<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ReactiveRemoveSupport<>(template, domainType, query, collection); return new ReactiveRemoveSupport<>(template, domainType, query, collection);
} }

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

@ -45,7 +45,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public <T> ReactiveUpdate<T> update(Class<T> domainType) { public <T> ReactiveUpdate<T> update(Class<T> domainType) {
Assert.notNull(domainType, "DomainType must not be null!"); Assert.notNull(domainType, "DomainType must not be null");
return new ReactiveUpdateSupport<>(template, domainType, ALL_QUERY, null, null, null, null, null, domainType); return new ReactiveUpdateSupport<>(template, domainType, ALL_QUERY, null, null, null, null, null, domainType);
} }
@ -82,7 +82,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public TerminatingUpdate<T> apply(org.springframework.data.mongodb.core.query.UpdateDefinition update) { public TerminatingUpdate<T> apply(org.springframework.data.mongodb.core.query.UpdateDefinition update) {
Assert.notNull(update, "Update must not be null!"); Assert.notNull(update, "Update must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -91,7 +91,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public UpdateWithQuery<T> inCollection(String collection) { public UpdateWithQuery<T> inCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -127,7 +127,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public UpdateWithUpdate<T> matching(Query query) { public UpdateWithUpdate<T> matching(Query query) {
Assert.notNull(query, "Query must not be null!"); Assert.notNull(query, "Query must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -141,7 +141,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options) { public TerminatingFindAndModify<T> withOptions(FindAndModifyOptions options) {
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, options, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, options,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -150,7 +150,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public FindAndReplaceWithProjection<T> replaceWith(T replacement) { public FindAndReplaceWithProjection<T> replaceWith(T replacement) {
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, targetType); findAndReplaceOptions, replacement, targetType);
@ -159,7 +159,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public FindAndReplaceWithProjection<T> withOptions(FindAndReplaceOptions options) { public FindAndReplaceWithProjection<T> withOptions(FindAndReplaceOptions options) {
Assert.notNull(options, "Options must not be null!"); Assert.notNull(options, "Options must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, options, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, options,
replacement, targetType); replacement, targetType);
@ -168,7 +168,7 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
@Override @Override
public <R> FindAndReplaceWithOptions<R> as(Class<R> resultType) { public <R> FindAndReplaceWithOptions<R> as(Class<R> resultType) {
Assert.notNull(resultType, "ResultType must not be null!"); Assert.notNull(resultType, "ResultType must not be null");
return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions, return new ReactiveUpdateSupport<>(template, domainType, query, update, collection, findAndModifyOptions,
findAndReplaceOptions, replacement, resultType); findAndReplaceOptions, replacement, resultType);

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

@ -77,10 +77,10 @@ public class SimpleReactiveMongoDatabaseFactory implements DisposableBean, React
private SimpleReactiveMongoDatabaseFactory(MongoClient client, String databaseName, boolean mongoInstanceCreated) { private SimpleReactiveMongoDatabaseFactory(MongoClient client, String databaseName, boolean mongoInstanceCreated) {
Assert.notNull(client, "MongoClient must not be null!"); Assert.notNull(client, "MongoClient must not be null");
Assert.hasText(databaseName, "Database name must not be empty!"); Assert.hasText(databaseName, "Database name must not be empty");
Assert.isTrue(databaseName.matches("[^/\\\\.$\"\\s]+"), Assert.isTrue(databaseName.matches("[^/\\\\.$\"\\s]+"),
"Database name must not contain slashes, dots, spaces, quotes, or dollar signs!"); "Database name must not contain slashes, dots, spaces, quotes, or dollar signs");
this.mongo = client; this.mongo = client;
this.databaseName = databaseName; this.databaseName = databaseName;
@ -103,7 +103,7 @@ public class SimpleReactiveMongoDatabaseFactory implements DisposableBean, React
public Mono<MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException { public Mono<MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException {
Assert.hasText(dbName, "Database name must not be empty."); Assert.hasText(dbName, "Database name must not be empty");
return Mono.fromSupplier(() -> { return Mono.fromSupplier(() -> {

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

@ -133,7 +133,7 @@ abstract class AbstractAggregationExpression implements AggregationExpression {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
protected Map<String, Object> append(String key, Object value) { protected Map<String, Object> append(String key, Object value) {
Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map!"); Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map");
Map<String, Object> clone = new LinkedHashMap<>((java.util.Map) this.value); Map<String, Object> clone = new LinkedHashMap<>((java.util.Map) this.value);
clone.put(key, value); clone.put(key, value);
@ -144,7 +144,7 @@ abstract class AbstractAggregationExpression implements AggregationExpression {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
protected Map<String, Object> remove(String key) { protected Map<String, Object> remove(String key) {
Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map!"); Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map");
Map<String, Object> clone = new LinkedHashMap<>((java.util.Map) this.value); Map<String, Object> clone = new LinkedHashMap<>((java.util.Map) this.value);
clone.remove(key); clone.remove(key);
@ -163,7 +163,7 @@ abstract class AbstractAggregationExpression implements AggregationExpression {
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
protected Map<String, Object> appendAt(int index, String key, Object value) { protected Map<String, Object> appendAt(int index, String key, Object value) {
Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map!"); Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map");
Map<String, Object> clone = new LinkedHashMap<>(); Map<String, Object> clone = new LinkedHashMap<>();
@ -223,7 +223,7 @@ abstract class AbstractAggregationExpression implements AggregationExpression {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <T> T get(Object key) { protected <T> T get(Object key) {
Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map!"); Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map");
return (T) ((Map<String, Object>) this.value).get(key); return (T) ((Map<String, Object>) this.value).get(key);
} }
@ -237,7 +237,7 @@ abstract class AbstractAggregationExpression implements AggregationExpression {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Map<String, Object> argumentMap() { protected Map<String, Object> argumentMap() {
Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map!"); Assert.isInstanceOf(Map.class, this.value, "Value must be a type of Map");
return Collections.unmodifiableMap((java.util.Map<String, Object>) value); return Collections.unmodifiableMap((java.util.Map<String, Object>) value);
} }

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

@ -65,7 +65,7 @@ public class AccumulatorOperators {
*/ */
public AccumulatorOperatorFactory(String fieldReference) { public AccumulatorOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
} }
@ -77,7 +77,7 @@ public class AccumulatorOperators {
*/ */
public AccumulatorOperatorFactory(AggregationExpression expression) { public AccumulatorOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
} }
@ -278,7 +278,7 @@ public class AccumulatorOperators {
*/ */
public static Sum sumOf(String fieldReference) { public static Sum sumOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Sum(asFields(fieldReference)); return new Sum(asFields(fieldReference));
} }
@ -290,7 +290,7 @@ public class AccumulatorOperators {
*/ */
public static Sum sumOf(AggregationExpression expression) { public static Sum sumOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Sum(Collections.singletonList(expression)); return new Sum(Collections.singletonList(expression));
} }
@ -303,7 +303,7 @@ public class AccumulatorOperators {
*/ */
public Sum and(String fieldReference) { public Sum and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Sum(append(Fields.field(fieldReference))); return new Sum(append(Fields.field(fieldReference)));
} }
@ -316,7 +316,7 @@ public class AccumulatorOperators {
*/ */
public Sum and(AggregationExpression expression) { public Sum and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Sum(append(expression)); return new Sum(append(expression));
} }
@ -330,7 +330,7 @@ public class AccumulatorOperators {
*/ */
public Sum and(Number value) { public Sum and(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Sum(append(value)); return new Sum(append(value));
} }
@ -372,7 +372,7 @@ public class AccumulatorOperators {
*/ */
public static Avg avgOf(String fieldReference) { public static Avg avgOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Avg(asFields(fieldReference)); return new Avg(asFields(fieldReference));
} }
@ -384,7 +384,7 @@ public class AccumulatorOperators {
*/ */
public static Avg avgOf(AggregationExpression expression) { public static Avg avgOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Avg(Collections.singletonList(expression)); return new Avg(Collections.singletonList(expression));
} }
@ -397,7 +397,7 @@ public class AccumulatorOperators {
*/ */
public Avg and(String fieldReference) { public Avg and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Avg(append(Fields.field(fieldReference))); return new Avg(append(Fields.field(fieldReference)));
} }
@ -410,7 +410,7 @@ public class AccumulatorOperators {
*/ */
public Avg and(AggregationExpression expression) { public Avg and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Avg(append(expression)); return new Avg(append(expression));
} }
@ -452,7 +452,7 @@ public class AccumulatorOperators {
*/ */
public static Max maxOf(String fieldReference) { public static Max maxOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Max(asFields(fieldReference)); return new Max(asFields(fieldReference));
} }
@ -464,7 +464,7 @@ public class AccumulatorOperators {
*/ */
public static Max maxOf(AggregationExpression expression) { public static Max maxOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Max(Collections.singletonList(expression)); return new Max(Collections.singletonList(expression));
} }
@ -477,7 +477,7 @@ public class AccumulatorOperators {
*/ */
public Max and(String fieldReference) { public Max and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Max(append(Fields.field(fieldReference))); return new Max(append(Fields.field(fieldReference)));
} }
@ -490,7 +490,7 @@ public class AccumulatorOperators {
*/ */
public Max and(AggregationExpression expression) { public Max and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Max(append(expression)); return new Max(append(expression));
} }
@ -532,7 +532,7 @@ public class AccumulatorOperators {
*/ */
public static Min minOf(String fieldReference) { public static Min minOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Min(asFields(fieldReference)); return new Min(asFields(fieldReference));
} }
@ -544,7 +544,7 @@ public class AccumulatorOperators {
*/ */
public static Min minOf(AggregationExpression expression) { public static Min minOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Min(Collections.singletonList(expression)); return new Min(Collections.singletonList(expression));
} }
@ -557,7 +557,7 @@ public class AccumulatorOperators {
*/ */
public Min and(String fieldReference) { public Min and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Min(append(Fields.field(fieldReference))); return new Min(append(Fields.field(fieldReference)));
} }
@ -570,7 +570,7 @@ public class AccumulatorOperators {
*/ */
public Min and(AggregationExpression expression) { public Min and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Min(append(expression)); return new Min(append(expression));
} }
@ -612,7 +612,7 @@ public class AccumulatorOperators {
*/ */
public static StdDevPop stdDevPopOf(String fieldReference) { public static StdDevPop stdDevPopOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new StdDevPop(asFields(fieldReference)); return new StdDevPop(asFields(fieldReference));
} }
@ -624,7 +624,7 @@ public class AccumulatorOperators {
*/ */
public static StdDevPop stdDevPopOf(AggregationExpression expression) { public static StdDevPop stdDevPopOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new StdDevPop(Collections.singletonList(expression)); return new StdDevPop(Collections.singletonList(expression));
} }
@ -637,7 +637,7 @@ public class AccumulatorOperators {
*/ */
public StdDevPop and(String fieldReference) { public StdDevPop and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new StdDevPop(append(Fields.field(fieldReference))); return new StdDevPop(append(Fields.field(fieldReference)));
} }
@ -650,7 +650,7 @@ public class AccumulatorOperators {
*/ */
public StdDevPop and(AggregationExpression expression) { public StdDevPop and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new StdDevPop(append(expression)); return new StdDevPop(append(expression));
} }
@ -692,7 +692,7 @@ public class AccumulatorOperators {
*/ */
public static StdDevSamp stdDevSampOf(String fieldReference) { public static StdDevSamp stdDevSampOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new StdDevSamp(asFields(fieldReference)); return new StdDevSamp(asFields(fieldReference));
} }
@ -704,7 +704,7 @@ public class AccumulatorOperators {
*/ */
public static StdDevSamp stdDevSampOf(AggregationExpression expression) { public static StdDevSamp stdDevSampOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new StdDevSamp(Collections.singletonList(expression)); return new StdDevSamp(Collections.singletonList(expression));
} }
@ -717,7 +717,7 @@ public class AccumulatorOperators {
*/ */
public StdDevSamp and(String fieldReference) { public StdDevSamp and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new StdDevSamp(append(Fields.field(fieldReference))); return new StdDevSamp(append(Fields.field(fieldReference)));
} }
@ -730,7 +730,7 @@ public class AccumulatorOperators {
*/ */
public StdDevSamp and(AggregationExpression expression) { public StdDevSamp and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new StdDevSamp(append(expression)); return new StdDevSamp(append(expression));
} }
@ -768,7 +768,7 @@ public class AccumulatorOperators {
*/ */
public static CovariancePop covariancePopOf(String fieldReference) { public static CovariancePop covariancePopOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new CovariancePop(asFields(fieldReference)); return new CovariancePop(asFields(fieldReference));
} }
@ -828,7 +828,7 @@ public class AccumulatorOperators {
*/ */
public static CovarianceSamp covarianceSampOf(String fieldReference) { public static CovarianceSamp covarianceSampOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new CovarianceSamp(asFields(fieldReference)); return new CovarianceSamp(asFields(fieldReference));
} }

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

@ -138,7 +138,7 @@ public class Aggregation {
*/ */
public Aggregation withOptions(AggregationOptions options) { public Aggregation withOptions(AggregationOptions options) {
Assert.notNull(options, "AggregationOptions must not be null."); Assert.notNull(options, "AggregationOptions must not be null");
return new Aggregation(this.pipeline.getOperations(), options); return new Aggregation(this.pipeline.getOperations(), options);
} }
@ -177,7 +177,7 @@ public class Aggregation {
*/ */
protected static List<AggregationOperation> asAggregationList(AggregationOperation... aggregationOperations) { protected static List<AggregationOperation> asAggregationList(AggregationOperation... aggregationOperations) {
Assert.notEmpty(aggregationOperations, "AggregationOperations must not be null or empty!"); Assert.notEmpty(aggregationOperations, "AggregationOperations must not be null or empty");
return Arrays.asList(aggregationOperations); return Arrays.asList(aggregationOperations);
} }
@ -199,8 +199,8 @@ public class Aggregation {
*/ */
protected Aggregation(List<AggregationOperation> aggregationOperations, AggregationOptions options) { protected Aggregation(List<AggregationOperation> aggregationOperations, AggregationOptions options) {
Assert.notNull(aggregationOperations, "AggregationOperations must not be null!"); Assert.notNull(aggregationOperations, "AggregationOperations must not be null");
Assert.notNull(options, "AggregationOptions must not be null!"); Assert.notNull(options, "AggregationOptions must not be null");
this.pipeline = new AggregationPipeline(aggregationOperations); this.pipeline = new AggregationPipeline(aggregationOperations);
this.options = options; this.options = options;
@ -267,7 +267,7 @@ public class Aggregation {
*/ */
public static ProjectionOperation project(Class<?> type) { public static ProjectionOperation project(Class<?> type) {
Assert.notNull(type, "Type must not be null!"); Assert.notNull(type, "Type must not be null");
return new ProjectionOperation(type); return new ProjectionOperation(type);
} }

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

@ -60,7 +60,7 @@ interface AggregationExpressionTransformer
super(currentNode, parentNode, previousOperationObject); super(currentNode, parentNode, previousOperationObject);
Assert.notNull(context, "AggregationOperationContext must not be null!"); Assert.notNull(context, "AggregationOperationContext must not be null");
this.aggregationContext = context; this.aggregationContext = context;
} }

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

@ -86,7 +86,7 @@ public interface AggregationOperationContext {
*/ */
default Fields getFields(Class<?> type) { default Fields getFields(Class<?> type) {
Assert.notNull(type, "Type must not be null!"); Assert.notNull(type, "Type must not be null");
return Fields.fields(Arrays.stream(BeanUtils.getPropertyDescriptors(type)) // return Fields.fields(Arrays.stream(BeanUtils.getPropertyDescriptors(type)) //
.filter(it -> { // object and default methods .filter(it -> { // object and default methods

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

@ -144,7 +144,7 @@ public class AggregationOptions {
*/ */
public static AggregationOptions fromDocument(Document document) { public static AggregationOptions fromDocument(Document document) {
Assert.notNull(document, "Document must not be null!"); Assert.notNull(document, "Document must not be null");
boolean allowDiskUse = document.getBoolean(ALLOW_DISK_USE, false); boolean allowDiskUse = document.getBoolean(ALLOW_DISK_USE, false);
boolean explain = document.getBoolean(EXPLAIN, false); boolean explain = document.getBoolean(EXPLAIN, false);

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

@ -48,7 +48,7 @@ public class AggregationPipeline {
*/ */
public AggregationPipeline(List<AggregationOperation> aggregationOperations) { public AggregationPipeline(List<AggregationOperation> aggregationOperations) {
Assert.notNull(aggregationOperations, "AggregationOperations must not be null!"); Assert.notNull(aggregationOperations, "AggregationOperations must not be null");
pipeline = new ArrayList<>(aggregationOperations); pipeline = new ArrayList<>(aggregationOperations);
} }
@ -60,7 +60,7 @@ public class AggregationPipeline {
*/ */
public AggregationPipeline add(AggregationOperation aggregationOperation) { public AggregationPipeline add(AggregationOperation aggregationOperation) {
Assert.notNull(aggregationOperation, "AggregationOperation must not be null!"); Assert.notNull(aggregationOperation, "AggregationOperation must not be null");
pipeline.add(aggregationOperation); pipeline.add(aggregationOperation);
return this; return this;
@ -100,11 +100,11 @@ public class AggregationPipeline {
for (AggregationOperation operation : pipeline) { for (AggregationOperation operation : pipeline) {
if (isOut(operation) && !isLast(operation)) { if (isOut(operation) && !isLast(operation)) {
throw new IllegalArgumentException("The $out operator must be the last stage in the pipeline."); throw new IllegalArgumentException("The $out operator must be the last stage in the pipeline");
} }
if (isMerge(operation) && !isLast(operation)) { if (isMerge(operation) && !isLast(operation)) {
throw new IllegalArgumentException("The $merge operator must be the last stage in the pipeline."); throw new IllegalArgumentException("The $merge operator must be the last stage in the pipeline");
} }
} }
} }

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

@ -48,8 +48,8 @@ public class AggregationResults<T> implements Iterable<T> {
*/ */
public AggregationResults(List<T> mappedResults, Document rawResults) { public AggregationResults(List<T> mappedResults, Document rawResults) {
Assert.notNull(mappedResults, "List of mapped results must not be null!"); Assert.notNull(mappedResults, "List of mapped results must not be null");
Assert.notNull(rawResults, "Raw results must not be null!"); Assert.notNull(rawResults, "Raw results must not be null");
this.mappedResults = Collections.unmodifiableList(mappedResults); this.mappedResults = Collections.unmodifiableList(mappedResults);
this.rawResults = rawResults; this.rawResults = rawResults;
@ -73,7 +73,7 @@ public class AggregationResults<T> implements Iterable<T> {
*/ */
@Nullable @Nullable
public T getUniqueMappedResult() { public T getUniqueMappedResult() {
Assert.isTrue(mappedResults.size() < 2, "Expected unique result or null, but got more than one!"); Assert.isTrue(mappedResults.size() < 2, "Expected unique result or null, but got more than one");
return mappedResults.size() == 1 ? mappedResults.get(0) : null; return mappedResults.size() == 1 ? mappedResults.get(0) : null;
} }

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

@ -60,7 +60,7 @@ public class AggregationSpELExpression implements AggregationExpression {
*/ */
public static AggregationSpELExpression expressionOf(String expressionString, Object... parameters) { public static AggregationSpELExpression expressionOf(String expressionString, Object... parameters) {
Assert.notNull(expressionString, "ExpressionString must not be null!"); Assert.notNull(expressionString, "ExpressionString must not be null");
return new AggregationSpELExpression(expressionString, parameters); return new AggregationSpELExpression(expressionString, parameters);
} }

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

@ -133,7 +133,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public AggregationUpdate set(SetOperation setOperation) { public AggregationUpdate set(SetOperation setOperation) {
Assert.notNull(setOperation, "SetOperation must not be null!"); Assert.notNull(setOperation, "SetOperation must not be null");
setOperation.getFields().forEach(it -> { setOperation.getFields().forEach(it -> {
keysTouched.add(it.getName()); keysTouched.add(it.getName());
@ -152,7 +152,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public AggregationUpdate unset(UnsetOperation unsetOperation) { public AggregationUpdate unset(UnsetOperation unsetOperation) {
Assert.notNull(unsetOperation, "UnsetOperation must not be null!"); Assert.notNull(unsetOperation, "UnsetOperation must not be null");
pipeline.add(unsetOperation); pipeline.add(unsetOperation);
keysTouched.addAll(unsetOperation.removedFieldNames()); keysTouched.addAll(unsetOperation.removedFieldNames());
@ -170,7 +170,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public AggregationUpdate replaceWith(ReplaceWithOperation replaceWithOperation) { public AggregationUpdate replaceWith(ReplaceWithOperation replaceWithOperation) {
Assert.notNull(replaceWithOperation, "ReplaceWithOperation must not be null!"); Assert.notNull(replaceWithOperation, "ReplaceWithOperation must not be null");
pipeline.add(replaceWithOperation); pipeline.add(replaceWithOperation);
return this; return this;
} }
@ -183,7 +183,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public AggregationUpdate replaceWith(Object value) { public AggregationUpdate replaceWith(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return replaceWith(ReplaceWithOperation.replaceWithValue(value)); return replaceWith(ReplaceWithOperation.replaceWithValue(value));
} }
@ -197,7 +197,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public SetValueAppender set(String key) { public SetValueAppender set(String key) {
Assert.notNull(key, "Key must not be null!"); Assert.notNull(key, "Key must not be null");
return new SetValueAppender() { return new SetValueAppender() {
@ -209,7 +209,7 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
@Override @Override
public AggregationUpdate toValueOf(Object value) { public AggregationUpdate toValueOf(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return set(SetOperation.builder().set(key).toValueOf(value)); return set(SetOperation.builder().set(key).toValueOf(value));
} }
}; };
@ -223,8 +223,8 @@ public class AggregationUpdate extends Aggregation implements UpdateDefinition {
*/ */
public AggregationUpdate unset(String... keys) { public AggregationUpdate unset(String... keys) {
Assert.notNull(keys, "Keys must not be null!"); Assert.notNull(keys, "Keys must not be null");
Assert.noNullElements(keys, "Keys must not contain null elements."); Assert.noNullElements(keys, "Keys must not contain null elements");
return unset(new UnsetOperation(Arrays.stream(keys).map(Fields::field).collect(Collectors.toList()))); return unset(new UnsetOperation(Arrays.stream(keys).map(Fields::field).collect(Collectors.toList())));
} }

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

@ -36,11 +36,11 @@ interface AggregationUtils {
*/ */
static List<Long> toRangeValues(Range<Long> range) { static List<Long> toRangeValues(Range<Long> range) {
Assert.notNull(range, "Range must not be null!"); Assert.notNull(range, "Range must not be null");
List<Long> result = new ArrayList<Long>(2); List<Long> result = new ArrayList<Long>(2);
result.add(range.getLowerBound().getValue() result.add(range.getLowerBound().getValue()
.orElseThrow(() -> new IllegalArgumentException("Lower bound of range must be bounded!"))); .orElseThrow(() -> new IllegalArgumentException("Lower bound of range must be bounded")));
range.getUpperBound().getValue().ifPresent(it -> result.add(it)); range.getUpperBound().getValue().ifPresent(it -> result.add(it));
return result; return result;

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

@ -91,7 +91,7 @@ public class ArithmeticOperators {
*/ */
public ArithmeticOperatorFactory(String fieldReference) { public ArithmeticOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
} }
@ -103,7 +103,7 @@ public class ArithmeticOperators {
*/ */
public ArithmeticOperatorFactory(AggregationExpression expression) { public ArithmeticOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
} }
@ -126,7 +126,7 @@ public class ArithmeticOperators {
*/ */
public Add add(String fieldReference) { public Add add(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createAdd().add(fieldReference); return createAdd().add(fieldReference);
} }
@ -139,7 +139,7 @@ public class ArithmeticOperators {
*/ */
public Add add(AggregationExpression expression) { public Add add(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createAdd().add(expression); return createAdd().add(expression);
} }
@ -151,7 +151,7 @@ public class ArithmeticOperators {
*/ */
public Add add(Number value) { public Add add(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createAdd().add(value); return createAdd().add(value);
} }
@ -218,7 +218,7 @@ public class ArithmeticOperators {
*/ */
public Divide divideBy(String fieldReference) { public Divide divideBy(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createDivide().divideBy(fieldReference); return createDivide().divideBy(fieldReference);
} }
@ -231,7 +231,7 @@ public class ArithmeticOperators {
*/ */
public Divide divideBy(AggregationExpression expression) { public Divide divideBy(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createDivide().divideBy(expression); return createDivide().divideBy(expression);
} }
@ -243,7 +243,7 @@ public class ArithmeticOperators {
*/ */
public Divide divideBy(Number value) { public Divide divideBy(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createDivide().divideBy(value); return createDivide().divideBy(value);
} }
@ -304,7 +304,7 @@ public class ArithmeticOperators {
*/ */
public Integral integral(String unit) { public Integral integral(String unit) {
Assert.hasText(unit, "Unit must not be empty!"); Assert.hasText(unit, "Unit must not be empty");
return integral().unit(unit); return integral().unit(unit);
} }
@ -328,7 +328,7 @@ public class ArithmeticOperators {
*/ */
public Log log(String fieldReference) { public Log log(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createLog().log(fieldReference); return createLog().log(fieldReference);
} }
@ -341,7 +341,7 @@ public class ArithmeticOperators {
*/ */
public Log log(AggregationExpression expression) { public Log log(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createLog().log(fieldReference); return createLog().log(fieldReference);
} }
@ -354,7 +354,7 @@ public class ArithmeticOperators {
*/ */
public Log log(Number base) { public Log log(Number base) {
Assert.notNull(base, "Base must not be null!"); Assert.notNull(base, "Base must not be null");
return createLog().log(base); return createLog().log(base);
} }
@ -380,7 +380,7 @@ public class ArithmeticOperators {
*/ */
public Mod mod(String fieldReference) { public Mod mod(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createMod().mod(fieldReference); return createMod().mod(fieldReference);
} }
@ -393,7 +393,7 @@ public class ArithmeticOperators {
*/ */
public Mod mod(AggregationExpression expression) { public Mod mod(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createMod().mod(expression); return createMod().mod(expression);
} }
@ -406,7 +406,7 @@ public class ArithmeticOperators {
*/ */
public Mod mod(Number value) { public Mod mod(Number value) {
Assert.notNull(value, "Base must not be null!"); Assert.notNull(value, "Base must not be null");
return createMod().mod(value); return createMod().mod(value);
} }
@ -422,7 +422,7 @@ public class ArithmeticOperators {
*/ */
public Multiply multiplyBy(String fieldReference) { public Multiply multiplyBy(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createMultiply().multiplyBy(fieldReference); return createMultiply().multiplyBy(fieldReference);
} }
@ -434,7 +434,7 @@ public class ArithmeticOperators {
*/ */
public Multiply multiplyBy(AggregationExpression expression) { public Multiply multiplyBy(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createMultiply().multiplyBy(expression); return createMultiply().multiplyBy(expression);
} }
@ -446,7 +446,7 @@ public class ArithmeticOperators {
*/ */
public Multiply multiplyBy(Number value) { public Multiply multiplyBy(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createMultiply().multiplyBy(value); return createMultiply().multiplyBy(value);
} }
@ -462,7 +462,7 @@ public class ArithmeticOperators {
*/ */
public Pow pow(String fieldReference) { public Pow pow(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createPow().pow(fieldReference); return createPow().pow(fieldReference);
} }
@ -474,7 +474,7 @@ public class ArithmeticOperators {
*/ */
public Pow pow(AggregationExpression expression) { public Pow pow(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createPow().pow(expression); return createPow().pow(expression);
} }
@ -486,7 +486,7 @@ public class ArithmeticOperators {
*/ */
public Pow pow(Number value) { public Pow pow(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createPow().pow(value); return createPow().pow(value);
} }
@ -511,7 +511,7 @@ public class ArithmeticOperators {
*/ */
public Subtract subtract(String fieldReference) { public Subtract subtract(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createSubtract().subtract(fieldReference); return createSubtract().subtract(fieldReference);
} }
@ -523,7 +523,7 @@ public class ArithmeticOperators {
*/ */
public Subtract subtract(AggregationExpression expression) { public Subtract subtract(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createSubtract().subtract(expression); return createSubtract().subtract(expression);
} }
@ -535,7 +535,7 @@ public class ArithmeticOperators {
*/ */
public Subtract subtract(Number value) { public Subtract subtract(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createSubtract().subtract(value); return createSubtract().subtract(value);
} }
@ -851,7 +851,7 @@ public class ArithmeticOperators {
*/ */
public ATan2 atan2(Number value) { public ATan2 atan2(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createATan2().atan2of(value); return createATan2().atan2of(value);
} }
@ -865,7 +865,7 @@ public class ArithmeticOperators {
*/ */
public ATan2 atan2(String fieldReference) { public ATan2 atan2(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createATan2().atan2of(fieldReference); return createATan2().atan2of(fieldReference);
} }
@ -879,7 +879,7 @@ public class ArithmeticOperators {
*/ */
public ATan2 atan2(AggregationExpression expression) { public ATan2 atan2(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createATan2().atan2of(expression); return createATan2().atan2of(expression);
} }
@ -961,7 +961,7 @@ public class ArithmeticOperators {
*/ */
public static Abs absoluteValueOf(String fieldReference) { public static Abs absoluteValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Abs(Fields.field(fieldReference)); return new Abs(Fields.field(fieldReference));
} }
@ -973,7 +973,7 @@ public class ArithmeticOperators {
*/ */
public static Abs absoluteValueOf(AggregationExpression expression) { public static Abs absoluteValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Abs(expression); return new Abs(expression);
} }
@ -985,7 +985,7 @@ public class ArithmeticOperators {
*/ */
public static Abs absoluteValueOf(Number value) { public static Abs absoluteValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Abs(value); return new Abs(value);
} }
} }
@ -1014,7 +1014,7 @@ public class ArithmeticOperators {
*/ */
public static Add valueOf(String fieldReference) { public static Add valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Add(asFields(fieldReference)); return new Add(asFields(fieldReference));
} }
@ -1026,7 +1026,7 @@ public class ArithmeticOperators {
*/ */
public static Add valueOf(AggregationExpression expression) { public static Add valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Add(Collections.singletonList(expression)); return new Add(Collections.singletonList(expression));
} }
@ -1038,7 +1038,7 @@ public class ArithmeticOperators {
*/ */
public static Add valueOf(Number value) { public static Add valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Add(Collections.singletonList(value)); return new Add(Collections.singletonList(value));
} }
@ -1050,7 +1050,7 @@ public class ArithmeticOperators {
*/ */
public Add add(String fieldReference) { public Add add(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Add(append(Fields.field(fieldReference))); return new Add(append(Fields.field(fieldReference)));
} }
@ -1062,7 +1062,7 @@ public class ArithmeticOperators {
*/ */
public Add add(AggregationExpression expression) { public Add add(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Add(append(expression)); return new Add(append(expression));
} }
@ -1101,7 +1101,7 @@ public class ArithmeticOperators {
*/ */
public static Ceil ceilValueOf(String fieldReference) { public static Ceil ceilValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Ceil(Fields.field(fieldReference)); return new Ceil(Fields.field(fieldReference));
} }
@ -1113,7 +1113,7 @@ public class ArithmeticOperators {
*/ */
public static Ceil ceilValueOf(AggregationExpression expression) { public static Ceil ceilValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Ceil(expression); return new Ceil(expression);
} }
@ -1125,7 +1125,7 @@ public class ArithmeticOperators {
*/ */
public static Ceil ceilValueOf(Number value) { public static Ceil ceilValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Ceil(value); return new Ceil(value);
} }
} }
@ -1154,7 +1154,7 @@ public class ArithmeticOperators {
*/ */
public static Divide valueOf(String fieldReference) { public static Divide valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Divide(asFields(fieldReference)); return new Divide(asFields(fieldReference));
} }
@ -1166,7 +1166,7 @@ public class ArithmeticOperators {
*/ */
public static Divide valueOf(AggregationExpression expression) { public static Divide valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Divide(Collections.singletonList(expression)); return new Divide(Collections.singletonList(expression));
} }
@ -1178,7 +1178,7 @@ public class ArithmeticOperators {
*/ */
public static Divide valueOf(Number value) { public static Divide valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Divide(Collections.singletonList(value)); return new Divide(Collections.singletonList(value));
} }
@ -1190,7 +1190,7 @@ public class ArithmeticOperators {
*/ */
public Divide divideBy(String fieldReference) { public Divide divideBy(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Divide(append(Fields.field(fieldReference))); return new Divide(append(Fields.field(fieldReference)));
} }
@ -1202,7 +1202,7 @@ public class ArithmeticOperators {
*/ */
public Divide divideBy(AggregationExpression expression) { public Divide divideBy(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Divide(append(expression)); return new Divide(append(expression));
} }
@ -1241,7 +1241,7 @@ public class ArithmeticOperators {
*/ */
public static Exp expValueOf(String fieldReference) { public static Exp expValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Exp(Fields.field(fieldReference)); return new Exp(Fields.field(fieldReference));
} }
@ -1253,7 +1253,7 @@ public class ArithmeticOperators {
*/ */
public static Exp expValueOf(AggregationExpression expression) { public static Exp expValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Exp(expression); return new Exp(expression);
} }
@ -1265,7 +1265,7 @@ public class ArithmeticOperators {
*/ */
public static Exp expValueOf(Number value) { public static Exp expValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Exp(value); return new Exp(value);
} }
} }
@ -1294,7 +1294,7 @@ public class ArithmeticOperators {
*/ */
public static Floor floorValueOf(String fieldReference) { public static Floor floorValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Floor(Fields.field(fieldReference)); return new Floor(Fields.field(fieldReference));
} }
@ -1306,7 +1306,7 @@ public class ArithmeticOperators {
*/ */
public static Floor floorValueOf(AggregationExpression expression) { public static Floor floorValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Floor(expression); return new Floor(expression);
} }
@ -1318,7 +1318,7 @@ public class ArithmeticOperators {
*/ */
public static Floor floorValueOf(Number value) { public static Floor floorValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Floor(value); return new Floor(value);
} }
} }
@ -1347,7 +1347,7 @@ public class ArithmeticOperators {
*/ */
public static Ln lnValueOf(String fieldReference) { public static Ln lnValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Ln(Fields.field(fieldReference)); return new Ln(Fields.field(fieldReference));
} }
@ -1359,7 +1359,7 @@ public class ArithmeticOperators {
*/ */
public static Ln lnValueOf(AggregationExpression expression) { public static Ln lnValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Ln(expression); return new Ln(expression);
} }
@ -1371,7 +1371,7 @@ public class ArithmeticOperators {
*/ */
public static Ln lnValueOf(Number value) { public static Ln lnValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Ln(value); return new Ln(value);
} }
} }
@ -1400,7 +1400,7 @@ public class ArithmeticOperators {
*/ */
public static Log valueOf(String fieldReference) { public static Log valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Log(asFields(fieldReference)); return new Log(asFields(fieldReference));
} }
@ -1412,7 +1412,7 @@ public class ArithmeticOperators {
*/ */
public static Log valueOf(AggregationExpression expression) { public static Log valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Log(Collections.singletonList(expression)); return new Log(Collections.singletonList(expression));
} }
@ -1424,7 +1424,7 @@ public class ArithmeticOperators {
*/ */
public static Log valueOf(Number value) { public static Log valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Log(Collections.singletonList(value)); return new Log(Collections.singletonList(value));
} }
@ -1436,7 +1436,7 @@ public class ArithmeticOperators {
*/ */
public Log log(String fieldReference) { public Log log(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Log(append(Fields.field(fieldReference))); return new Log(append(Fields.field(fieldReference)));
} }
@ -1448,7 +1448,7 @@ public class ArithmeticOperators {
*/ */
public Log log(AggregationExpression expression) { public Log log(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Log(append(expression)); return new Log(append(expression));
} }
@ -1487,7 +1487,7 @@ public class ArithmeticOperators {
*/ */
public static Log10 log10ValueOf(String fieldReference) { public static Log10 log10ValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Log10(Fields.field(fieldReference)); return new Log10(Fields.field(fieldReference));
} }
@ -1499,7 +1499,7 @@ public class ArithmeticOperators {
*/ */
public static Log10 log10ValueOf(AggregationExpression expression) { public static Log10 log10ValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Log10(expression); return new Log10(expression);
} }
@ -1511,7 +1511,7 @@ public class ArithmeticOperators {
*/ */
public static Log10 log10ValueOf(Number value) { public static Log10 log10ValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Log10(value); return new Log10(value);
} }
} }
@ -1540,7 +1540,7 @@ public class ArithmeticOperators {
*/ */
public static Mod valueOf(String fieldReference) { public static Mod valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Mod(asFields(fieldReference)); return new Mod(asFields(fieldReference));
} }
@ -1552,7 +1552,7 @@ public class ArithmeticOperators {
*/ */
public static Mod valueOf(AggregationExpression expression) { public static Mod valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Mod(Collections.singletonList(expression)); return new Mod(Collections.singletonList(expression));
} }
@ -1564,7 +1564,7 @@ public class ArithmeticOperators {
*/ */
public static Mod valueOf(Number value) { public static Mod valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Mod(Collections.singletonList(value)); return new Mod(Collections.singletonList(value));
} }
@ -1576,7 +1576,7 @@ public class ArithmeticOperators {
*/ */
public Mod mod(String fieldReference) { public Mod mod(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Mod(append(Fields.field(fieldReference))); return new Mod(append(Fields.field(fieldReference)));
} }
@ -1588,7 +1588,7 @@ public class ArithmeticOperators {
*/ */
public Mod mod(AggregationExpression expression) { public Mod mod(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Mod(append(expression)); return new Mod(append(expression));
} }
@ -1627,7 +1627,7 @@ public class ArithmeticOperators {
*/ */
public static Multiply valueOf(String fieldReference) { public static Multiply valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Multiply(asFields(fieldReference)); return new Multiply(asFields(fieldReference));
} }
@ -1639,7 +1639,7 @@ public class ArithmeticOperators {
*/ */
public static Multiply valueOf(AggregationExpression expression) { public static Multiply valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Multiply(Collections.singletonList(expression)); return new Multiply(Collections.singletonList(expression));
} }
@ -1651,7 +1651,7 @@ public class ArithmeticOperators {
*/ */
public static Multiply valueOf(Number value) { public static Multiply valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Multiply(Collections.singletonList(value)); return new Multiply(Collections.singletonList(value));
} }
@ -1663,7 +1663,7 @@ public class ArithmeticOperators {
*/ */
public Multiply multiplyBy(String fieldReference) { public Multiply multiplyBy(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Multiply(append(Fields.field(fieldReference))); return new Multiply(append(Fields.field(fieldReference)));
} }
@ -1675,7 +1675,7 @@ public class ArithmeticOperators {
*/ */
public Multiply multiplyBy(AggregationExpression expression) { public Multiply multiplyBy(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Multiply(append(expression)); return new Multiply(append(expression));
} }
@ -1714,7 +1714,7 @@ public class ArithmeticOperators {
*/ */
public static Pow valueOf(String fieldReference) { public static Pow valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Pow(asFields(fieldReference)); return new Pow(asFields(fieldReference));
} }
@ -1726,7 +1726,7 @@ public class ArithmeticOperators {
*/ */
public static Pow valueOf(AggregationExpression expression) { public static Pow valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Pow(Collections.singletonList(expression)); return new Pow(Collections.singletonList(expression));
} }
@ -1738,7 +1738,7 @@ public class ArithmeticOperators {
*/ */
public static Pow valueOf(Number value) { public static Pow valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Pow(Collections.singletonList(value)); return new Pow(Collections.singletonList(value));
} }
@ -1750,7 +1750,7 @@ public class ArithmeticOperators {
*/ */
public Pow pow(String fieldReference) { public Pow pow(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Pow(append(Fields.field(fieldReference))); return new Pow(append(Fields.field(fieldReference)));
} }
@ -1762,7 +1762,7 @@ public class ArithmeticOperators {
*/ */
public Pow pow(AggregationExpression expression) { public Pow pow(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Pow(append(expression)); return new Pow(append(expression));
} }
@ -1801,7 +1801,7 @@ public class ArithmeticOperators {
*/ */
public static Sqrt sqrtOf(String fieldReference) { public static Sqrt sqrtOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Sqrt(Fields.field(fieldReference)); return new Sqrt(Fields.field(fieldReference));
} }
@ -1813,7 +1813,7 @@ public class ArithmeticOperators {
*/ */
public static Sqrt sqrtOf(AggregationExpression expression) { public static Sqrt sqrtOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Sqrt(expression); return new Sqrt(expression);
} }
@ -1825,7 +1825,7 @@ public class ArithmeticOperators {
*/ */
public static Sqrt sqrtOf(Number value) { public static Sqrt sqrtOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Sqrt(value); return new Sqrt(value);
} }
} }
@ -1854,7 +1854,7 @@ public class ArithmeticOperators {
*/ */
public static Subtract valueOf(String fieldReference) { public static Subtract valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Subtract(asFields(fieldReference)); return new Subtract(asFields(fieldReference));
} }
@ -1866,7 +1866,7 @@ public class ArithmeticOperators {
*/ */
public static Subtract valueOf(AggregationExpression expression) { public static Subtract valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Subtract(Collections.singletonList(expression)); return new Subtract(Collections.singletonList(expression));
} }
@ -1878,7 +1878,7 @@ public class ArithmeticOperators {
*/ */
public static Subtract valueOf(Number value) { public static Subtract valueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Subtract(Collections.singletonList(value)); return new Subtract(Collections.singletonList(value));
} }
@ -1890,7 +1890,7 @@ public class ArithmeticOperators {
*/ */
public Subtract subtract(String fieldReference) { public Subtract subtract(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Subtract(append(Fields.field(fieldReference))); return new Subtract(append(Fields.field(fieldReference)));
} }
@ -1902,7 +1902,7 @@ public class ArithmeticOperators {
*/ */
public Subtract subtract(AggregationExpression expression) { public Subtract subtract(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Subtract(append(expression)); return new Subtract(append(expression));
} }
@ -1941,7 +1941,7 @@ public class ArithmeticOperators {
*/ */
public static Trunc truncValueOf(String fieldReference) { public static Trunc truncValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Trunc(Fields.field(fieldReference)); return new Trunc(Fields.field(fieldReference));
} }
@ -1953,7 +1953,7 @@ public class ArithmeticOperators {
*/ */
public static Trunc truncValueOf(AggregationExpression expression) { public static Trunc truncValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Trunc(expression); return new Trunc(expression);
} }
@ -1965,7 +1965,7 @@ public class ArithmeticOperators {
*/ */
public static Trunc truncValueOf(Number value) { public static Trunc truncValueOf(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Trunc(value); return new Trunc(value);
} }
} }
@ -1997,7 +1997,7 @@ public class ArithmeticOperators {
*/ */
public static Round roundValueOf(String fieldReference) { public static Round roundValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Round(Collections.singletonList(Fields.field(fieldReference))); return new Round(Collections.singletonList(Fields.field(fieldReference)));
} }
@ -2009,7 +2009,7 @@ public class ArithmeticOperators {
*/ */
public static Round roundValueOf(AggregationExpression expression) { public static Round roundValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Round(Collections.singletonList(expression)); return new Round(Collections.singletonList(expression));
} }
@ -2021,7 +2021,7 @@ public class ArithmeticOperators {
*/ */
public static Round round(Number value) { public static Round round(Number value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Round(Collections.singletonList(value)); return new Round(Collections.singletonList(value));
} }
@ -2043,7 +2043,7 @@ public class ArithmeticOperators {
*/ */
public Round placeOf(AggregationExpression expression) { public Round placeOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Round(append(expression)); return new Round(append(expression));
} }
@ -2056,7 +2056,7 @@ public class ArithmeticOperators {
*/ */
public Round placeOf(String fieldReference) { public Round placeOf(String fieldReference) {
Assert.notNull(fieldReference, "fieldReference must not be null!"); Assert.notNull(fieldReference, "fieldReference must not be null");
return new Round(append(Fields.field(fieldReference))); return new Round(append(Fields.field(fieldReference)));
} }
@ -2400,7 +2400,7 @@ public class ArithmeticOperators {
*/ */
public static ASin asinOf(String fieldReference) { public static ASin asinOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ASin(Fields.field(fieldReference)); return new ASin(Fields.field(fieldReference));
} }
@ -2704,7 +2704,7 @@ public class ArithmeticOperators {
*/ */
public static ACos acosOf(String fieldReference) { public static ACos acosOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ACos(Fields.field(fieldReference)); return new ACos(Fields.field(fieldReference));
} }
@ -2905,7 +2905,7 @@ public class ArithmeticOperators {
*/ */
public static ATan atanOf(String fieldReference) { public static ATan atanOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ATan(Fields.field(fieldReference)); return new ATan(Fields.field(fieldReference));
} }
@ -2958,7 +2958,7 @@ public class ArithmeticOperators {
*/ */
public static ATan2 valueOf(String fieldReference) { public static ATan2 valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ATan2(asFields(fieldReference)); return new ATan2(asFields(fieldReference));
} }
@ -2971,7 +2971,7 @@ public class ArithmeticOperators {
*/ */
public static ATan2 valueOf(AggregationExpression expression) { public static ATan2 valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ATan2((Collections.singletonList(expression))); return new ATan2((Collections.singletonList(expression)));
} }
@ -2985,7 +2985,7 @@ public class ArithmeticOperators {
*/ */
public ATan2 atan2of(String fieldReference) { public ATan2 atan2of(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ATan2(append(Fields.field(fieldReference))); return new ATan2(append(Fields.field(fieldReference)));
} }
@ -2999,7 +2999,7 @@ public class ArithmeticOperators {
*/ */
public ATan2 atan2of(AggregationExpression expression) { public ATan2 atan2of(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ATan2(append(expression)); return new ATan2(append(expression));
} }

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

@ -87,7 +87,7 @@ public class ArrayOperators {
*/ */
public ArrayOperatorFactory(String fieldReference) { public ArrayOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
this.values = null; this.values = null;
@ -100,7 +100,7 @@ public class ArrayOperators {
*/ */
public ArrayOperatorFactory(AggregationExpression expression) { public ArrayOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
this.values = null; this.values = null;
@ -114,7 +114,7 @@ public class ArrayOperators {
*/ */
public ArrayOperatorFactory(Collection<?> values) { public ArrayOperatorFactory(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = null; this.expression = null;
this.values = values; this.values = values;
@ -140,7 +140,7 @@ public class ArrayOperators {
*/ */
public ArrayElemAt elementAt(AggregationExpression expression) { public ArrayElemAt elementAt(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createArrayElemAt().elementAt(expression); return createArrayElemAt().elementAt(expression);
} }
@ -153,7 +153,7 @@ public class ArrayOperators {
*/ */
public ArrayElemAt elementAt(String fieldReference) { public ArrayElemAt elementAt(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createArrayElemAt().elementAt(fieldReference); return createArrayElemAt().elementAt(fieldReference);
} }
@ -175,7 +175,7 @@ public class ArrayOperators {
*/ */
public ConcatArrays concat(String arrayFieldReference) { public ConcatArrays concat(String arrayFieldReference) {
Assert.notNull(arrayFieldReference, "ArrayFieldReference must not be null!"); Assert.notNull(arrayFieldReference, "ArrayFieldReference must not be null");
return createConcatArrays().concat(arrayFieldReference); return createConcatArrays().concat(arrayFieldReference);
} }
@ -188,7 +188,7 @@ public class ArrayOperators {
*/ */
public ConcatArrays concat(AggregationExpression expression) { public ConcatArrays concat(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createConcatArrays().concat(expression); return createConcatArrays().concat(expression);
} }
@ -213,7 +213,7 @@ public class ArrayOperators {
return Filter.filter(fieldReference); return Filter.filter(fieldReference);
} }
Assert.state(values != null, "Values must not be null!"); Assert.state(values != null, "Values must not be null");
return Filter.filter(new ArrayList<>(values)); return Filter.filter(new ArrayList<>(values));
} }
@ -224,7 +224,7 @@ public class ArrayOperators {
*/ */
public IsArray isArray() { public IsArray isArray() {
Assert.state(values == null, "Does it make sense to call isArray on an array? Maybe just skip it?"); Assert.state(values == null, "Does it make sense to call isArray on an array; Maybe just skip it");
return usesFieldRef() ? IsArray.isArray(fieldReference) : IsArray.isArray(expression); return usesFieldRef() ? IsArray.isArray(fieldReference) : IsArray.isArray(expression);
} }
@ -363,7 +363,7 @@ public class ArrayOperators {
return usesExpression() ? ArrayToObject.arrayValueOfToObject(expression) : ArrayToObject.arrayToObject(values); return usesExpression() ? ArrayToObject.arrayValueOfToObject(expression) : ArrayToObject.arrayToObject(values);
} }
/** /**
* Creates new {@link AggregationExpression} that return the first element in the associated array. * Creates new {@link AggregationExpression} that return the first element in the associated array.
* <strong>NOTE:</strong> Requires MongoDB 4.4 or later. * <strong>NOTE:</strong> Requires MongoDB 4.4 or later.
@ -379,7 +379,7 @@ public class ArrayOperators {
return usesExpression() ? First.firstOf(expression) : First.first(values); return usesExpression() ? First.firstOf(expression) : First.first(values);
} }
/** /**
* Creates new {@link AggregationExpression} that return the last element in the given array. * Creates new {@link AggregationExpression} that return the last element in the given array.
* <strong>NOTE:</strong> Requires MongoDB 4.4 or later. * <strong>NOTE:</strong> Requires MongoDB 4.4 or later.
@ -450,7 +450,7 @@ public class ArrayOperators {
*/ */
public static ArrayElemAt arrayOf(String fieldReference) { public static ArrayElemAt arrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ArrayElemAt(asFields(fieldReference)); return new ArrayElemAt(asFields(fieldReference));
} }
@ -462,7 +462,7 @@ public class ArrayOperators {
*/ */
public static ArrayElemAt arrayOf(AggregationExpression expression) { public static ArrayElemAt arrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ArrayElemAt(Collections.singletonList(expression)); return new ArrayElemAt(Collections.singletonList(expression));
} }
@ -475,7 +475,7 @@ public class ArrayOperators {
*/ */
public static ArrayElemAt arrayOf(Collection<?> values) { public static ArrayElemAt arrayOf(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new ArrayElemAt(Collections.singletonList(values)); return new ArrayElemAt(Collections.singletonList(values));
} }
@ -497,7 +497,7 @@ public class ArrayOperators {
*/ */
public ArrayElemAt elementAt(AggregationExpression expression) { public ArrayElemAt elementAt(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ArrayElemAt(append(expression)); return new ArrayElemAt(append(expression));
} }
@ -509,7 +509,7 @@ public class ArrayOperators {
*/ */
public ArrayElemAt elementAt(String arrayFieldReference) { public ArrayElemAt elementAt(String arrayFieldReference) {
Assert.notNull(arrayFieldReference, "ArrayReference must not be null!"); Assert.notNull(arrayFieldReference, "ArrayReference must not be null");
return new ArrayElemAt(append(Fields.field(arrayFieldReference))); return new ArrayElemAt(append(Fields.field(arrayFieldReference)));
} }
} }
@ -538,7 +538,7 @@ public class ArrayOperators {
*/ */
public static ConcatArrays arrayOf(String fieldReference) { public static ConcatArrays arrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ConcatArrays(asFields(fieldReference)); return new ConcatArrays(asFields(fieldReference));
} }
@ -550,7 +550,7 @@ public class ArrayOperators {
*/ */
public static ConcatArrays arrayOf(AggregationExpression expression) { public static ConcatArrays arrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ConcatArrays(Collections.singletonList(expression)); return new ConcatArrays(Collections.singletonList(expression));
} }
@ -563,7 +563,7 @@ public class ArrayOperators {
*/ */
public static ConcatArrays arrayOf(Collection<?> values) { public static ConcatArrays arrayOf(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new ConcatArrays(Collections.singletonList(values)); return new ConcatArrays(Collections.singletonList(values));
} }
@ -575,7 +575,7 @@ public class ArrayOperators {
*/ */
public ConcatArrays concat(String arrayFieldReference) { public ConcatArrays concat(String arrayFieldReference) {
Assert.notNull(arrayFieldReference, "ArrayFieldReference must not be null!"); Assert.notNull(arrayFieldReference, "ArrayFieldReference must not be null");
return new ConcatArrays(append(Fields.field(arrayFieldReference))); return new ConcatArrays(append(Fields.field(arrayFieldReference)));
} }
@ -587,7 +587,7 @@ public class ArrayOperators {
*/ */
public ConcatArrays concat(AggregationExpression expression) { public ConcatArrays concat(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ConcatArrays(append(expression)); return new ConcatArrays(append(expression));
} }
} }
@ -617,7 +617,7 @@ public class ArrayOperators {
*/ */
public static AsBuilder filter(String field) { public static AsBuilder filter(String field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
return filter(Fields.field(field)); return filter(Fields.field(field));
} }
@ -629,7 +629,7 @@ public class ArrayOperators {
*/ */
public static AsBuilder filter(Field field) { public static AsBuilder filter(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
return new FilterExpressionBuilder().filter(field); return new FilterExpressionBuilder().filter(field);
} }
@ -641,7 +641,7 @@ public class ArrayOperators {
*/ */
public static AsBuilder filter(List<?> values) { public static AsBuilder filter(List<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new FilterExpressionBuilder().filter(values); return new FilterExpressionBuilder().filter(values);
} }
@ -768,7 +768,7 @@ public class ArrayOperators {
@Override @Override
public AsBuilder filter(List<?> array) { public AsBuilder filter(List<?> array) {
Assert.notNull(array, "Array must not be null!"); Assert.notNull(array, "Array must not be null");
filter.input = new ArrayList<Object>(array); filter.input = new ArrayList<Object>(array);
return this; return this;
} }
@ -776,7 +776,7 @@ public class ArrayOperators {
@Override @Override
public AsBuilder filter(Field field) { public AsBuilder filter(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
filter.input = field; filter.input = field;
return this; return this;
} }
@ -784,7 +784,7 @@ public class ArrayOperators {
@Override @Override
public ConditionBuilder as(String variableName) { public ConditionBuilder as(String variableName) {
Assert.notNull(variableName, "Variable name must not be null!"); Assert.notNull(variableName, "Variable name must not be null");
filter.as = new ExposedField(variableName, true); filter.as = new ExposedField(variableName, true);
return this; return this;
} }
@ -792,7 +792,7 @@ public class ArrayOperators {
@Override @Override
public Filter by(AggregationExpression condition) { public Filter by(AggregationExpression condition) {
Assert.notNull(condition, "Condition must not be null!"); Assert.notNull(condition, "Condition must not be null");
filter.condition = condition; filter.condition = condition;
return filter; return filter;
} }
@ -800,7 +800,7 @@ public class ArrayOperators {
@Override @Override
public Filter by(String expression) { public Filter by(String expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
filter.condition = expression; filter.condition = expression;
return filter; return filter;
} }
@ -808,7 +808,7 @@ public class ArrayOperators {
@Override @Override
public Filter by(Document expression) { public Filter by(Document expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
filter.condition = expression; filter.condition = expression;
return filter; return filter;
} }
@ -839,7 +839,7 @@ public class ArrayOperators {
*/ */
public static IsArray isArray(String fieldReference) { public static IsArray isArray(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new IsArray(Fields.field(fieldReference)); return new IsArray(Fields.field(fieldReference));
} }
@ -851,7 +851,7 @@ public class ArrayOperators {
*/ */
public static IsArray isArray(AggregationExpression expression) { public static IsArray isArray(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new IsArray(expression); return new IsArray(expression);
} }
} }
@ -880,7 +880,7 @@ public class ArrayOperators {
*/ */
public static Size lengthOfArray(String fieldReference) { public static Size lengthOfArray(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Size(Fields.field(fieldReference)); return new Size(Fields.field(fieldReference));
} }
@ -892,7 +892,7 @@ public class ArrayOperators {
*/ */
public static Size lengthOfArray(AggregationExpression expression) { public static Size lengthOfArray(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Size(expression); return new Size(expression);
} }
@ -905,7 +905,7 @@ public class ArrayOperators {
*/ */
public static Size lengthOfArray(Collection<?> values) { public static Size lengthOfArray(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new Size(Collections.singletonList(values)); return new Size(Collections.singletonList(values));
} }
} }
@ -934,7 +934,7 @@ public class ArrayOperators {
*/ */
public static Slice sliceArrayOf(String fieldReference) { public static Slice sliceArrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Slice(asFields(fieldReference)); return new Slice(asFields(fieldReference));
} }
@ -946,7 +946,7 @@ public class ArrayOperators {
*/ */
public static Slice sliceArrayOf(AggregationExpression expression) { public static Slice sliceArrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Slice(Collections.singletonList(expression)); return new Slice(Collections.singletonList(expression));
} }
@ -959,7 +959,7 @@ public class ArrayOperators {
*/ */
public static Slice sliceArrayOf(Collection<?> values) { public static Slice sliceArrayOf(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new Slice(Collections.singletonList(values)); return new Slice(Collections.singletonList(values));
} }
@ -1029,7 +1029,7 @@ public class ArrayOperators {
*/ */
public static IndexOfArrayBuilder arrayOf(String fieldReference) { public static IndexOfArrayBuilder arrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new IndexOfArrayBuilder(Fields.field(fieldReference)); return new IndexOfArrayBuilder(Fields.field(fieldReference));
} }
@ -1041,7 +1041,7 @@ public class ArrayOperators {
*/ */
public static IndexOfArrayBuilder arrayOf(AggregationExpression expression) { public static IndexOfArrayBuilder arrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new IndexOfArrayBuilder(expression); return new IndexOfArrayBuilder(expression);
} }
@ -1054,7 +1054,7 @@ public class ArrayOperators {
*/ */
public static IndexOfArrayBuilder arrayOf(Collection<?> values) { public static IndexOfArrayBuilder arrayOf(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return new IndexOfArrayBuilder(values); return new IndexOfArrayBuilder(values);
} }
@ -1087,7 +1087,7 @@ public class ArrayOperators {
*/ */
public IndexOfArray indexOf(Object value) { public IndexOfArray indexOf(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new IndexOfArray(Arrays.asList(targetArray, value)); return new IndexOfArray(Arrays.asList(targetArray, value));
} }
} }
@ -1411,8 +1411,8 @@ public class ArrayOperators {
protected PropertyExpression(String propertyName, AggregationExpression aggregationExpression) { protected PropertyExpression(String propertyName, AggregationExpression aggregationExpression) {
Assert.notNull(propertyName, "Property name must not be null!"); Assert.notNull(propertyName, "Property name must not be null");
Assert.notNull(aggregationExpression, "AggregationExpression must not be null!"); Assert.notNull(aggregationExpression, "AggregationExpression must not be null");
this.propertyName = propertyName; this.propertyName = propertyName;
this.aggregationExpression = aggregationExpression; this.aggregationExpression = aggregationExpression;
@ -1559,7 +1559,7 @@ public class ArrayOperators {
*/ */
public static ZipBuilder arrayOf(String fieldReference) { public static ZipBuilder arrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new ZipBuilder(Fields.field(fieldReference)); return new ZipBuilder(Fields.field(fieldReference));
} }
@ -1571,7 +1571,7 @@ public class ArrayOperators {
*/ */
public static ZipBuilder arrayOf(AggregationExpression expression) { public static ZipBuilder arrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new ZipBuilder(expression); return new ZipBuilder(expression);
} }
@ -1584,7 +1584,7 @@ public class ArrayOperators {
*/ */
public static ZipBuilder arrayOf(Collection<?> values) { public static ZipBuilder arrayOf(Collection<?> values) {
Assert.notNull(values, "Expression must not be null!"); Assert.notNull(values, "Expression must not be null");
return new ZipBuilder(values); return new ZipBuilder(values);
} }
@ -1605,7 +1605,7 @@ public class ArrayOperators {
*/ */
public Zip defaultTo(String fieldReference) { public Zip defaultTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Zip(append("defaults", Fields.field(fieldReference))); return new Zip(append("defaults", Fields.field(fieldReference)));
} }
@ -1617,7 +1617,7 @@ public class ArrayOperators {
*/ */
public Zip defaultTo(AggregationExpression expression) { public Zip defaultTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Zip(append("defaults", expression)); return new Zip(append("defaults", expression));
} }
@ -1629,7 +1629,7 @@ public class ArrayOperators {
*/ */
public Zip defaultTo(Object[] array) { public Zip defaultTo(Object[] array) {
Assert.notNull(array, "Array must not be null!"); Assert.notNull(array, "Array must not be null");
return new Zip(append("defaults", Arrays.asList(array))); return new Zip(append("defaults", Arrays.asList(array)));
} }
@ -1653,7 +1653,7 @@ public class ArrayOperators {
*/ */
public Zip zip(Object... arrays) { public Zip zip(Object... arrays) {
Assert.notNull(arrays, "Arrays must not be null!"); Assert.notNull(arrays, "Arrays must not be null");
for (Object value : arrays) { for (Object value : arrays) {
if (value instanceof String) { if (value instanceof String) {
@ -1696,11 +1696,11 @@ public class ArrayOperators {
*/ */
public static InBuilder arrayOf(String fieldReference) { public static InBuilder arrayOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return value -> { return value -> {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new In(Arrays.asList(value, Fields.field(fieldReference))); return new In(Arrays.asList(value, Fields.field(fieldReference)));
}; };
} }
@ -1713,11 +1713,11 @@ public class ArrayOperators {
*/ */
public static InBuilder arrayOf(AggregationExpression expression) { public static InBuilder arrayOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return value -> { return value -> {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new In(Arrays.asList(value, expression)); return new In(Arrays.asList(value, expression));
}; };
@ -1732,11 +1732,11 @@ public class ArrayOperators {
*/ */
public static InBuilder arrayOf(Collection<?> values) { public static InBuilder arrayOf(Collection<?> values) {
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
return value -> { return value -> {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new In(Arrays.asList(value, values)); return new In(Arrays.asList(value, values));
}; };
@ -1807,7 +1807,7 @@ public class ArrayOperators {
return "$arrayToObject"; return "$arrayToObject";
} }
} }
/** /**
* {@link AggregationExpression} for {@code $first} that returns the first element in an array. <br /> * {@link AggregationExpression} for {@code $first} that returns the first element in an array. <br />
* <strong>NOTE:</strong> Requires MongoDB 4.4 or later. * <strong>NOTE:</strong> Requires MongoDB 4.4 or later.
@ -1861,7 +1861,7 @@ public class ArrayOperators {
return "$first"; return "$first";
} }
} }
/** /**
* {@link AggregationExpression} for {@code $last} that returns the last element in an array. <br /> * {@link AggregationExpression} for {@code $last} that returns the last element in an array. <br />
* <strong>NOTE:</strong> Requires MongoDB 4.4 or later. * <strong>NOTE:</strong> Requires MongoDB 4.4 or later.

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

@ -87,7 +87,7 @@ public class BooleanOperators {
*/ */
public BooleanOperatorFactory(String fieldReference) { public BooleanOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
} }
@ -99,7 +99,7 @@ public class BooleanOperators {
*/ */
public BooleanOperatorFactory(AggregationExpression expression) { public BooleanOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
} }
@ -113,7 +113,7 @@ public class BooleanOperators {
*/ */
public And and(AggregationExpression expression) { public And and(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createAnd().andExpression(expression); return createAnd().andExpression(expression);
} }
@ -126,7 +126,7 @@ public class BooleanOperators {
*/ */
public And and(String fieldReference) { public And and(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createAnd().andField(fieldReference); return createAnd().andField(fieldReference);
} }
@ -143,7 +143,7 @@ public class BooleanOperators {
*/ */
public Or or(AggregationExpression expression) { public Or or(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createOr().orExpression(expression); return createOr().orExpression(expression);
} }
@ -156,7 +156,7 @@ public class BooleanOperators {
*/ */
public Or or(String fieldReference) { public Or or(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createOr().orField(fieldReference); return createOr().orField(fieldReference);
} }
@ -213,7 +213,7 @@ public class BooleanOperators {
*/ */
public And andExpression(AggregationExpression expression) { public And andExpression(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new And(append(expression)); return new And(append(expression));
} }
@ -225,7 +225,7 @@ public class BooleanOperators {
*/ */
public And andField(String fieldReference) { public And andField(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new And(append(Fields.field(fieldReference))); return new And(append(Fields.field(fieldReference)));
} }
@ -237,7 +237,7 @@ public class BooleanOperators {
*/ */
public And andValue(Object value) { public And andValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new And(append(value)); return new And(append(value));
} }
} }
@ -267,7 +267,7 @@ public class BooleanOperators {
*/ */
public static Or or(Object... expressions) { public static Or or(Object... expressions) {
Assert.notNull(expressions, "Expressions must not be null!"); Assert.notNull(expressions, "Expressions must not be null");
return new Or(Arrays.asList(expressions)); return new Or(Arrays.asList(expressions));
} }
@ -279,7 +279,7 @@ public class BooleanOperators {
*/ */
public Or orExpression(AggregationExpression expression) { public Or orExpression(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Or(append(expression)); return new Or(append(expression));
} }
@ -291,7 +291,7 @@ public class BooleanOperators {
*/ */
public Or orField(String fieldReference) { public Or orField(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Or(append(Fields.field(fieldReference))); return new Or(append(Fields.field(fieldReference)));
} }
@ -303,7 +303,7 @@ public class BooleanOperators {
*/ */
public Or orValue(Object value) { public Or orValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Or(append(value)); return new Or(append(value));
} }
} }
@ -333,7 +333,7 @@ public class BooleanOperators {
*/ */
public static Not not(String fieldReference) { public static Not not(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Not(asFields(fieldReference)); return new Not(asFields(fieldReference));
} }
@ -346,7 +346,7 @@ public class BooleanOperators {
*/ */
public static Not not(AggregationExpression expression) { public static Not not(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Not(Collections.singletonList(expression)); return new Not(Collections.singletonList(expression));
} }
} }

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

@ -50,7 +50,7 @@ public class BucketAutoOperation extends BucketOperationSupport<BucketAutoOperat
super(groupByField); super(groupByField);
Assert.isTrue(buckets > 0, "Number of buckets must be greater 0!"); Assert.isTrue(buckets > 0, "Number of buckets must be greater 0");
this.buckets = buckets; this.buckets = buckets;
this.granularity = null; this.granularity = null;
@ -66,7 +66,7 @@ public class BucketAutoOperation extends BucketOperationSupport<BucketAutoOperat
super(groupByExpression); super(groupByExpression);
Assert.isTrue(buckets > 0, "Number of buckets must be greater 0!"); Assert.isTrue(buckets > 0, "Number of buckets must be greater 0");
this.buckets = buckets; this.buckets = buckets;
this.granularity = null; this.granularity = null;
@ -117,7 +117,7 @@ public class BucketAutoOperation extends BucketOperationSupport<BucketAutoOperat
*/ */
public BucketAutoOperation withBuckets(int buckets) { public BucketAutoOperation withBuckets(int buckets) {
Assert.isTrue(buckets > 0, "Number of buckets must be greater 0!"); Assert.isTrue(buckets > 0, "Number of buckets must be greater 0");
return new BucketAutoOperation(this, buckets, granularity); return new BucketAutoOperation(this, buckets, granularity);
} }
@ -132,7 +132,7 @@ public class BucketAutoOperation extends BucketOperationSupport<BucketAutoOperat
*/ */
public BucketAutoOperation withGranularity(Granularity granularity) { public BucketAutoOperation withGranularity(Granularity granularity) {
Assert.notNull(granularity, "Granularity must not be null!"); Assert.notNull(granularity, "Granularity must not be null");
return new BucketAutoOperation(this, buckets, granularity.getMongoRepresentation()); return new BucketAutoOperation(this, buckets, granularity.getMongoRepresentation());
} }

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

@ -113,7 +113,7 @@ public class BucketOperation extends BucketOperationSupport<BucketOperation, Buc
*/ */
public BucketOperation withDefaultBucket(Object literal) { public BucketOperation withDefaultBucket(Object literal) {
Assert.notNull(literal, "Default bucket literal must not be null!"); Assert.notNull(literal, "Default bucket literal must not be null");
return new BucketOperation(this, boundaries, literal); return new BucketOperation(this, boundaries, literal);
} }
@ -126,8 +126,8 @@ public class BucketOperation extends BucketOperationSupport<BucketOperation, Buc
*/ */
public BucketOperation withBoundaries(Object... boundaries) { public BucketOperation withBoundaries(Object... boundaries) {
Assert.notNull(boundaries, "Boundaries must not be null!"); Assert.notNull(boundaries, "Boundaries must not be null");
Assert.noNullElements(boundaries, "Boundaries must not contain null values!"); Assert.noNullElements(boundaries, "Boundaries must not contain null values");
List<Object> newBoundaries = new ArrayList<Object>(this.boundaries.size() + boundaries.length); List<Object> newBoundaries = new ArrayList<Object>(this.boundaries.size() + boundaries.length);
newBoundaries.addAll(this.boundaries); newBoundaries.addAll(this.boundaries);

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

@ -51,7 +51,7 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected BucketOperationSupport(Field groupByField) { protected BucketOperationSupport(Field groupByField) {
Assert.notNull(groupByField, "Group by field must not be null!"); Assert.notNull(groupByField, "Group by field must not be null");
this.groupByField = groupByField; this.groupByField = groupByField;
this.groupByExpression = null; this.groupByExpression = null;
@ -65,7 +65,7 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected BucketOperationSupport(AggregationExpression groupByExpression) { protected BucketOperationSupport(AggregationExpression groupByExpression) {
Assert.notNull(groupByExpression, "Group by AggregationExpression must not be null!"); Assert.notNull(groupByExpression, "Group by AggregationExpression must not be null");
this.groupByExpression = groupByExpression; this.groupByExpression = groupByExpression;
this.groupByField = null; this.groupByField = null;
@ -89,8 +89,8 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected BucketOperationSupport(BucketOperationSupport<?, ?> operationSupport, Outputs outputs) { protected BucketOperationSupport(BucketOperationSupport<?, ?> operationSupport, Outputs outputs) {
Assert.notNull(operationSupport, "BucketOperationSupport must not be null!"); Assert.notNull(operationSupport, "BucketOperationSupport must not be null");
Assert.notNull(outputs, "Outputs must not be null!"); Assert.notNull(outputs, "Outputs must not be null");
this.groupByField = operationSupport.groupByField; this.groupByField = operationSupport.groupByField;
this.groupByExpression = operationSupport.groupByExpression; this.groupByExpression = operationSupport.groupByExpression;
@ -213,8 +213,8 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected OutputBuilder(Object value, T operation) { protected OutputBuilder(Object value, T operation) {
Assert.notNull(value, "Value must not be null or empty!"); Assert.notNull(value, "Value must not be null or empty");
Assert.notNull(operation, "ProjectionOperation must not be null!"); Assert.notNull(operation, "ProjectionOperation must not be null");
this.value = value; this.value = value;
this.operation = operation; this.operation = operation;
@ -321,8 +321,8 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
public B apply(String operation, Object... values) { public B apply(String operation, Object... values) {
Assert.hasText(operation, "Operation must not be empty or null!"); Assert.hasText(operation, "Operation must not be empty or null");
Assert.notNull(value, "Values must not be null!"); Assert.notNull(value, "Values must not be null");
List<Object> objects = new ArrayList<Object>(values.length + 1); List<Object> objects = new ArrayList<Object>(values.length + 1);
objects.add(value); objects.add(value);
@ -355,7 +355,7 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
} }
if (value instanceof Field) { if (value instanceof Field) {
throw new IllegalStateException("Cannot add a field as top-level output. Use accumulator expressions."); throw new IllegalStateException("Cannot add a field as top-level output; Use accumulator expressions");
} }
return this.operation return this.operation
@ -437,7 +437,7 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected Outputs and(Output output) { protected Outputs and(Output output) {
Assert.notNull(output, "BucketOutput must not be null!"); Assert.notNull(output, "BucketOutput must not be null");
return new Outputs(this.outputs, output); return new Outputs(this.outputs, output);
} }
@ -480,7 +480,7 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
*/ */
protected Output(Field field) { protected Output(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
this.field = new ExposedField(field, true); this.field = new ExposedField(field, true);
} }
@ -516,8 +516,8 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
super(Fields.field(operation)); super(Fields.field(operation));
Assert.hasText(operation, "Operation must not be null or empty!"); Assert.hasText(operation, "Operation must not be null or empty");
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
this.operation = operation; this.operation = operation;
this.values = new ArrayList<Object>(values); this.values = new ArrayList<Object>(values);
@ -616,8 +616,8 @@ public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,
super(Fields.field(expression)); super(Fields.field(expression));
Assert.hasText(expression, "Expression must not be null!"); Assert.hasText(expression, "Expression must not be null");
Assert.notNull(parameters, "Parameters must not be null!"); Assert.notNull(parameters, "Parameters must not be null");
this.expression = expression; this.expression = expression;
this.params = parameters.clone(); this.params = parameters.clone();

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

@ -60,7 +60,7 @@ public class ComparisonOperators {
*/ */
public ComparisonOperatorFactory(String fieldReference) { public ComparisonOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
} }
@ -72,7 +72,7 @@ public class ComparisonOperators {
*/ */
public ComparisonOperatorFactory(AggregationExpression expression) { public ComparisonOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
} }
@ -362,7 +362,7 @@ public class ComparisonOperators {
*/ */
public static Cmp valueOf(String fieldReference) { public static Cmp valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Cmp(asFields(fieldReference)); return new Cmp(asFields(fieldReference));
} }
@ -374,7 +374,7 @@ public class ComparisonOperators {
*/ */
public static Cmp valueOf(AggregationExpression expression) { public static Cmp valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Cmp(Collections.singletonList(expression)); return new Cmp(Collections.singletonList(expression));
} }
@ -386,7 +386,7 @@ public class ComparisonOperators {
*/ */
public Cmp compareTo(String fieldReference) { public Cmp compareTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Cmp(append(Fields.field(fieldReference))); return new Cmp(append(Fields.field(fieldReference)));
} }
@ -398,7 +398,7 @@ public class ComparisonOperators {
*/ */
public Cmp compareTo(AggregationExpression expression) { public Cmp compareTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Cmp(append(expression)); return new Cmp(append(expression));
} }
@ -410,7 +410,7 @@ public class ComparisonOperators {
*/ */
public Cmp compareToValue(Object value) { public Cmp compareToValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Cmp(append(value, Expand.KEEP_SOURCE)); return new Cmp(append(value, Expand.KEEP_SOURCE));
} }
} }
@ -439,7 +439,7 @@ public class ComparisonOperators {
*/ */
public static Eq valueOf(String fieldReference) { public static Eq valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Eq(asFields(fieldReference)); return new Eq(asFields(fieldReference));
} }
@ -451,7 +451,7 @@ public class ComparisonOperators {
*/ */
public static Eq valueOf(AggregationExpression expression) { public static Eq valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Eq(Collections.singletonList(expression)); return new Eq(Collections.singletonList(expression));
} }
@ -463,7 +463,7 @@ public class ComparisonOperators {
*/ */
public Eq equalTo(String fieldReference) { public Eq equalTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Eq(append(Fields.field(fieldReference))); return new Eq(append(Fields.field(fieldReference)));
} }
@ -475,7 +475,7 @@ public class ComparisonOperators {
*/ */
public Eq equalTo(AggregationExpression expression) { public Eq equalTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Eq(append(expression)); return new Eq(append(expression));
} }
@ -487,7 +487,7 @@ public class ComparisonOperators {
*/ */
public Eq equalToValue(Object value) { public Eq equalToValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Eq(append(value, Expand.KEEP_SOURCE)); return new Eq(append(value, Expand.KEEP_SOURCE));
} }
} }
@ -516,7 +516,7 @@ public class ComparisonOperators {
*/ */
public static Gt valueOf(String fieldReference) { public static Gt valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Gt(asFields(fieldReference)); return new Gt(asFields(fieldReference));
} }
@ -528,7 +528,7 @@ public class ComparisonOperators {
*/ */
public static Gt valueOf(AggregationExpression expression) { public static Gt valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Gt(Collections.singletonList(expression)); return new Gt(Collections.singletonList(expression));
} }
@ -540,7 +540,7 @@ public class ComparisonOperators {
*/ */
public Gt greaterThan(String fieldReference) { public Gt greaterThan(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Gt(append(Fields.field(fieldReference))); return new Gt(append(Fields.field(fieldReference)));
} }
@ -552,7 +552,7 @@ public class ComparisonOperators {
*/ */
public Gt greaterThan(AggregationExpression expression) { public Gt greaterThan(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Gt(append(expression)); return new Gt(append(expression));
} }
@ -564,7 +564,7 @@ public class ComparisonOperators {
*/ */
public Gt greaterThanValue(Object value) { public Gt greaterThanValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Gt(append(value)); return new Gt(append(value));
} }
} }
@ -593,7 +593,7 @@ public class ComparisonOperators {
*/ */
public static Lt valueOf(String fieldReference) { public static Lt valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Lt(asFields(fieldReference)); return new Lt(asFields(fieldReference));
} }
@ -605,7 +605,7 @@ public class ComparisonOperators {
*/ */
public static Lt valueOf(AggregationExpression expression) { public static Lt valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Lt(Collections.singletonList(expression)); return new Lt(Collections.singletonList(expression));
} }
@ -617,7 +617,7 @@ public class ComparisonOperators {
*/ */
public Lt lessThan(String fieldReference) { public Lt lessThan(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Lt(append(Fields.field(fieldReference))); return new Lt(append(Fields.field(fieldReference)));
} }
@ -629,7 +629,7 @@ public class ComparisonOperators {
*/ */
public Lt lessThan(AggregationExpression expression) { public Lt lessThan(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Lt(append(expression)); return new Lt(append(expression));
} }
@ -641,7 +641,7 @@ public class ComparisonOperators {
*/ */
public Lt lessThanValue(Object value) { public Lt lessThanValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Lt(append(value)); return new Lt(append(value));
} }
} }
@ -670,7 +670,7 @@ public class ComparisonOperators {
*/ */
public static Gte valueOf(String fieldReference) { public static Gte valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Gte(asFields(fieldReference)); return new Gte(asFields(fieldReference));
} }
@ -682,7 +682,7 @@ public class ComparisonOperators {
*/ */
public static Gte valueOf(AggregationExpression expression) { public static Gte valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Gte(Collections.singletonList(expression)); return new Gte(Collections.singletonList(expression));
} }
@ -694,7 +694,7 @@ public class ComparisonOperators {
*/ */
public Gte greaterThanEqualTo(String fieldReference) { public Gte greaterThanEqualTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Gte(append(Fields.field(fieldReference))); return new Gte(append(Fields.field(fieldReference)));
} }
@ -706,7 +706,7 @@ public class ComparisonOperators {
*/ */
public Gte greaterThanEqualTo(AggregationExpression expression) { public Gte greaterThanEqualTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Gte(append(expression)); return new Gte(append(expression));
} }
@ -718,7 +718,7 @@ public class ComparisonOperators {
*/ */
public Gte greaterThanEqualToValue(Object value) { public Gte greaterThanEqualToValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Gte(append(value)); return new Gte(append(value));
} }
} }
@ -747,7 +747,7 @@ public class ComparisonOperators {
*/ */
public static Lte valueOf(String fieldReference) { public static Lte valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Lte(asFields(fieldReference)); return new Lte(asFields(fieldReference));
} }
@ -759,7 +759,7 @@ public class ComparisonOperators {
*/ */
public static Lte valueOf(AggregationExpression expression) { public static Lte valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Lte(Collections.singletonList(expression)); return new Lte(Collections.singletonList(expression));
} }
@ -771,7 +771,7 @@ public class ComparisonOperators {
*/ */
public Lte lessThanEqualTo(String fieldReference) { public Lte lessThanEqualTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Lte(append(Fields.field(fieldReference))); return new Lte(append(Fields.field(fieldReference)));
} }
@ -783,7 +783,7 @@ public class ComparisonOperators {
*/ */
public Lte lessThanEqualTo(AggregationExpression expression) { public Lte lessThanEqualTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Lte(append(expression)); return new Lte(append(expression));
} }
@ -795,7 +795,7 @@ public class ComparisonOperators {
*/ */
public Lte lessThanEqualToValue(Object value) { public Lte lessThanEqualToValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Lte(append(value)); return new Lte(append(value));
} }
} }
@ -824,7 +824,7 @@ public class ComparisonOperators {
*/ */
public static Ne valueOf(String fieldReference) { public static Ne valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Ne(asFields(fieldReference)); return new Ne(asFields(fieldReference));
} }
@ -836,7 +836,7 @@ public class ComparisonOperators {
*/ */
public static Ne valueOf(AggregationExpression expression) { public static Ne valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Ne(Collections.singletonList(expression)); return new Ne(Collections.singletonList(expression));
} }
@ -848,7 +848,7 @@ public class ComparisonOperators {
*/ */
public Ne notEqualTo(String fieldReference) { public Ne notEqualTo(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Ne(append(Fields.field(fieldReference))); return new Ne(append(Fields.field(fieldReference)));
} }
@ -860,7 +860,7 @@ public class ComparisonOperators {
*/ */
public Ne notEqualTo(AggregationExpression expression) { public Ne notEqualTo(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Ne(append(expression)); return new Ne(append(expression));
} }
@ -872,7 +872,7 @@ public class ComparisonOperators {
*/ */
public Ne notEqualToValue(Object value) { public Ne notEqualToValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Ne(append(value, Expand.KEEP_SOURCE)); return new Ne(append(value, Expand.KEEP_SOURCE));
} }
} }

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

@ -80,7 +80,7 @@ public class ConditionalOperators {
*/ */
public static IfNull.ThenBuilder ifNull(String fieldReference) { public static IfNull.ThenBuilder ifNull(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return IfNull.ifNull(fieldReference); return IfNull.ifNull(fieldReference);
} }
@ -94,7 +94,7 @@ public class ConditionalOperators {
*/ */
public static IfNull.ThenBuilder ifNull(AggregationExpression expression) { public static IfNull.ThenBuilder ifNull(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return IfNull.ifNull(expression); return IfNull.ifNull(expression);
} }
@ -137,7 +137,7 @@ public class ConditionalOperators {
*/ */
public ConditionalOperatorFactory(String fieldReference) { public ConditionalOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
@ -151,7 +151,7 @@ public class ConditionalOperators {
*/ */
public ConditionalOperatorFactory(AggregationExpression expression) { public ConditionalOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
@ -165,7 +165,7 @@ public class ConditionalOperators {
*/ */
public ConditionalOperatorFactory(CriteriaDefinition criteriaDefinition) { public ConditionalOperatorFactory(CriteriaDefinition criteriaDefinition) {
Assert.notNull(criteriaDefinition, "CriteriaDefinition must not be null!"); Assert.notNull(criteriaDefinition, "CriteriaDefinition must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = null; this.expression = null;
@ -181,7 +181,7 @@ public class ConditionalOperators {
*/ */
public OtherwiseBuilder then(Object value) { public OtherwiseBuilder then(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return createThenBuilder().then(value); return createThenBuilder().then(value);
} }
@ -194,7 +194,7 @@ public class ConditionalOperators {
*/ */
public OtherwiseBuilder thenValueOf(AggregationExpression expression) { public OtherwiseBuilder thenValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return createThenBuilder().then(expression); return createThenBuilder().then(expression);
} }
@ -207,7 +207,7 @@ public class ConditionalOperators {
*/ */
public OtherwiseBuilder thenValueOf(String fieldReference) { public OtherwiseBuilder thenValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return createThenBuilder().thenValueOf(fieldReference); return createThenBuilder().thenValueOf(fieldReference);
} }
@ -258,7 +258,7 @@ public class ConditionalOperators {
*/ */
public static ThenBuilder ifNull(String fieldReference) { public static ThenBuilder ifNull(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new IfNullOperatorBuilder().ifNull(fieldReference); return new IfNullOperatorBuilder().ifNull(fieldReference);
} }
@ -271,7 +271,7 @@ public class ConditionalOperators {
*/ */
public static ThenBuilder ifNull(AggregationExpression expression) { public static ThenBuilder ifNull(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new IfNullOperatorBuilder().ifNull(expression); return new IfNullOperatorBuilder().ifNull(expression);
} }
@ -406,7 +406,7 @@ public class ConditionalOperators {
public ThenBuilder ifNull(String fieldReference) { public ThenBuilder ifNull(String fieldReference) {
Assert.hasText(fieldReference, "FieldReference name must not be null or empty!"); Assert.hasText(fieldReference, "FieldReference name must not be null or empty");
this.conditions.add(Fields.field(fieldReference)); this.conditions.add(Fields.field(fieldReference));
return this; return this;
} }
@ -414,7 +414,7 @@ public class ConditionalOperators {
@Override @Override
public ThenBuilder ifNull(AggregationExpression expression) { public ThenBuilder ifNull(AggregationExpression expression) {
Assert.notNull(expression, "AggregationExpression name must not be null or empty!"); Assert.notNull(expression, "AggregationExpression name must not be null or empty");
this.conditions.add(expression); this.conditions.add(expression);
return this; return this;
} }
@ -435,13 +435,13 @@ public class ConditionalOperators {
public IfNull thenValueOf(String fieldReference) { public IfNull thenValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new IfNull(conditions, Fields.field(fieldReference)); return new IfNull(conditions, Fields.field(fieldReference));
} }
public IfNull thenValueOf(AggregationExpression expression) { public IfNull thenValueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new IfNull(conditions, expression); return new IfNull(conditions, expression);
} }
} }
@ -470,7 +470,7 @@ public class ConditionalOperators {
*/ */
public static Switch switchCases(CaseOperator... conditions) { public static Switch switchCases(CaseOperator... conditions) {
Assert.notNull(conditions, "Conditions must not be null!"); Assert.notNull(conditions, "Conditions must not be null");
return switchCases(Arrays.asList(conditions)); return switchCases(Arrays.asList(conditions));
} }
@ -481,7 +481,7 @@ public class ConditionalOperators {
*/ */
public static Switch switchCases(List<CaseOperator> conditions) { public static Switch switchCases(List<CaseOperator> conditions) {
Assert.notNull(conditions, "Conditions must not be null!"); Assert.notNull(conditions, "Conditions must not be null");
return new Switch(Collections.<String, Object> singletonMap("branches", new ArrayList<CaseOperator>(conditions))); return new Switch(Collections.<String, Object> singletonMap("branches", new ArrayList<CaseOperator>(conditions)));
} }
@ -511,14 +511,14 @@ public class ConditionalOperators {
public static ThenBuilder when(final AggregationExpression condition) { public static ThenBuilder when(final AggregationExpression condition) {
Assert.notNull(condition, "Condition must not be null!"); Assert.notNull(condition, "Condition must not be null");
return new ThenBuilder() { return new ThenBuilder() {
@Override @Override
public CaseOperator then(Object value) { public CaseOperator then(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new CaseOperator(condition, value); return new CaseOperator(condition, value);
} }
}; };
@ -598,9 +598,9 @@ public class ConditionalOperators {
private Cond(Object condition, Object thenValue, Object otherwiseValue) { private Cond(Object condition, Object thenValue, Object otherwiseValue) {
Assert.notNull(condition, "Condition must not be null!"); Assert.notNull(condition, "Condition must not be null");
Assert.notNull(thenValue, "Then value must not be null!"); Assert.notNull(thenValue, "Then value must not be null");
Assert.notNull(otherwiseValue, "Otherwise value must not be null!"); Assert.notNull(otherwiseValue, "Otherwise value must not be null");
assertNotBuilder(condition, "Condition"); assertNotBuilder(condition, "Condition");
assertNotBuilder(thenValue, "Then value"); assertNotBuilder(thenValue, "Then value");
@ -657,7 +657,7 @@ public class ConditionalOperators {
} }
throw new InvalidDataAccessApiUsageException( throw new InvalidDataAccessApiUsageException(
String.format("Invalid value in condition. Supported: Document, Field references, Criteria, got: %s", value)); String.format("Invalid value in condition; Supported: Document, Field references, Criteria, got: %s", value));
} }
private List<Object> getClauses(AggregationOperationContext context, Document mappedObject) { private List<Object> getClauses(AggregationOperationContext context, Document mappedObject) {
@ -892,7 +892,7 @@ public class ConditionalOperators {
@Override @Override
public ConditionalExpressionBuilder when(Document booleanExpression) { public ConditionalExpressionBuilder when(Document booleanExpression) {
Assert.notNull(booleanExpression, "'Boolean expression' must not be null!"); Assert.notNull(booleanExpression, "'Boolean expression' must not be null");
this.condition = booleanExpression; this.condition = booleanExpression;
return this; return this;
@ -901,7 +901,7 @@ public class ConditionalOperators {
@Override @Override
public ThenBuilder when(CriteriaDefinition criteria) { public ThenBuilder when(CriteriaDefinition criteria) {
Assert.notNull(criteria, "Criteria must not be null!"); Assert.notNull(criteria, "Criteria must not be null");
this.condition = criteria; this.condition = criteria;
return this; return this;
} }
@ -909,7 +909,7 @@ public class ConditionalOperators {
@Override @Override
public ThenBuilder when(AggregationExpression expression) { public ThenBuilder when(AggregationExpression expression) {
Assert.notNull(expression, "AggregationExpression field must not be null!"); Assert.notNull(expression, "AggregationExpression field must not be null");
this.condition = expression; this.condition = expression;
return this; return this;
} }
@ -917,7 +917,7 @@ public class ConditionalOperators {
@Override @Override
public ThenBuilder when(String booleanField) { public ThenBuilder when(String booleanField) {
Assert.hasText(booleanField, "Boolean field name must not be null or empty!"); Assert.hasText(booleanField, "Boolean field name must not be null or empty");
this.condition = Fields.field(booleanField); this.condition = Fields.field(booleanField);
return this; return this;
} }
@ -925,7 +925,7 @@ public class ConditionalOperators {
@Override @Override
public OtherwiseBuilder then(Object thenValue) { public OtherwiseBuilder then(Object thenValue) {
Assert.notNull(thenValue, "Then-value must not be null!"); Assert.notNull(thenValue, "Then-value must not be null");
this.thenValue = thenValue; this.thenValue = thenValue;
return this; return this;
} }
@ -933,7 +933,7 @@ public class ConditionalOperators {
@Override @Override
public OtherwiseBuilder thenValueOf(String fieldReference) { public OtherwiseBuilder thenValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.thenValue = Fields.field(fieldReference); this.thenValue = Fields.field(fieldReference);
return this; return this;
} }
@ -941,7 +941,7 @@ public class ConditionalOperators {
@Override @Override
public OtherwiseBuilder thenValueOf(AggregationExpression expression) { public OtherwiseBuilder thenValueOf(AggregationExpression expression) {
Assert.notNull(expression, "AggregationExpression must not be null!"); Assert.notNull(expression, "AggregationExpression must not be null");
this.thenValue = expression; this.thenValue = expression;
return this; return this;
} }
@ -949,21 +949,21 @@ public class ConditionalOperators {
@Override @Override
public Cond otherwise(Object otherwiseValue) { public Cond otherwise(Object otherwiseValue) {
Assert.notNull(otherwiseValue, "Value must not be null!"); Assert.notNull(otherwiseValue, "Value must not be null");
return new Cond(condition, thenValue, otherwiseValue); return new Cond(condition, thenValue, otherwiseValue);
} }
@Override @Override
public Cond otherwiseValueOf(String fieldReference) { public Cond otherwiseValueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Cond(condition, thenValue, Fields.field(fieldReference)); return new Cond(condition, thenValue, Fields.field(fieldReference));
} }
@Override @Override
public Cond otherwiseValueOf(AggregationExpression expression) { public Cond otherwiseValueOf(AggregationExpression expression) {
Assert.notNull(expression, "AggregationExpression must not be null!"); Assert.notNull(expression, "AggregationExpression must not be null");
return new Cond(condition, thenValue, expression); return new Cond(condition, thenValue, expression);
} }
} }

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

@ -64,7 +64,7 @@ public class ConvertOperators {
*/ */
public ConvertOperatorFactory(String fieldReference) { public ConvertOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
@ -77,7 +77,7 @@ public class ConvertOperators {
*/ */
public ConvertOperatorFactory(AggregationExpression expression) { public ConvertOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;

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

@ -39,7 +39,7 @@ public class CountOperation implements FieldsExposingAggregationOperation {
*/ */
public CountOperation(String fieldName) { public CountOperation(String fieldName) {
Assert.hasText(fieldName, "Field name must not be null or empty!"); Assert.hasText(fieldName, "Field name must not be null or empty");
this.fieldName = fieldName; this.fieldName = fieldName;
} }

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

@ -60,7 +60,7 @@ public class DataTypeOperators {
*/ */
public static Type typeOf(String field) { public static Type typeOf(String field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
return new Type(Fields.field(field)); return new Type(Fields.field(field));
} }
} }

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

@ -48,7 +48,7 @@ public class DateOperators {
*/ */
public static DateOperatorFactory dateOf(String fieldReference) { public static DateOperatorFactory dateOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new DateOperatorFactory(fieldReference); return new DateOperatorFactory(fieldReference);
} }
@ -61,7 +61,7 @@ public class DateOperators {
*/ */
public static DateOperatorFactory zonedDateOf(String fieldReference, Timezone timezone) { public static DateOperatorFactory zonedDateOf(String fieldReference, Timezone timezone) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new DateOperatorFactory(fieldReference).withTimezone(timezone); return new DateOperatorFactory(fieldReference).withTimezone(timezone);
} }
@ -73,7 +73,7 @@ public class DateOperators {
*/ */
public static DateOperatorFactory dateOf(AggregationExpression expression) { public static DateOperatorFactory dateOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new DateOperatorFactory(expression); return new DateOperatorFactory(expression);
} }
@ -86,7 +86,7 @@ public class DateOperators {
*/ */
public static DateOperatorFactory zonedDateOf(AggregationExpression expression, Timezone timezone) { public static DateOperatorFactory zonedDateOf(AggregationExpression expression, Timezone timezone) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new DateOperatorFactory(expression).withTimezone(timezone); return new DateOperatorFactory(expression).withTimezone(timezone);
} }
@ -109,7 +109,7 @@ public class DateOperators {
*/ */
public static DateOperatorFactory dateValue(Object value) { public static DateOperatorFactory dateValue(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new DateOperatorFactory(value); return new DateOperatorFactory(value);
} }
@ -194,7 +194,7 @@ public class DateOperators {
*/ */
public static Timezone valueOf(Object value) { public static Timezone valueOf(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Timezone(value); return new Timezone(value);
} }
@ -207,7 +207,7 @@ public class DateOperators {
*/ */
public static Timezone fromOffset(TimeZone timeZone) { public static Timezone fromOffset(TimeZone timeZone) {
Assert.notNull(timeZone, "TimeZone must not be null!"); Assert.notNull(timeZone, "TimeZone must not be null");
return fromOffset( return fromOffset(
ZoneOffset.ofTotalSeconds(Math.toIntExact(TimeUnit.MILLISECONDS.toSeconds(timeZone.getRawOffset())))); ZoneOffset.ofTotalSeconds(Math.toIntExact(TimeUnit.MILLISECONDS.toSeconds(timeZone.getRawOffset()))));
@ -222,7 +222,7 @@ public class DateOperators {
*/ */
public static Timezone fromOffset(ZoneOffset offset) { public static Timezone fromOffset(ZoneOffset offset) {
Assert.notNull(offset, "ZoneOffset must not be null!"); Assert.notNull(offset, "ZoneOffset must not be null");
return new Timezone(offset.toString()); return new Timezone(offset.toString());
} }
@ -235,7 +235,7 @@ public class DateOperators {
*/ */
public static Timezone fromZone(TimeZone timeZone) { public static Timezone fromZone(TimeZone timeZone) {
Assert.notNull(timeZone, "TimeZone must not be null!"); Assert.notNull(timeZone, "TimeZone must not be null");
return valueOf(timeZone.getID()); return valueOf(timeZone.getID());
} }
@ -249,7 +249,7 @@ public class DateOperators {
*/ */
public static Timezone fromZone(ZoneId zoneId) { public static Timezone fromZone(ZoneId zoneId) {
Assert.notNull(zoneId, "ZoneId must not be null!"); Assert.notNull(zoneId, "ZoneId must not be null");
return new Timezone(zoneId.toString()); return new Timezone(zoneId.toString());
} }
@ -316,7 +316,7 @@ public class DateOperators {
this(fieldReference, null, null, Timezone.none()); this(fieldReference, null, null, Timezone.none());
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
} }
/** /**
@ -328,7 +328,7 @@ public class DateOperators {
this(null, expression, null, Timezone.none()); this(null, expression, null, Timezone.none());
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
} }
/** /**
@ -348,7 +348,7 @@ public class DateOperators {
this(null, null, value, Timezone.none()); this(null, null, value, Timezone.none());
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
} }
/** /**
@ -362,7 +362,7 @@ public class DateOperators {
*/ */
public DateOperatorFactory withTimezone(Timezone timezone) { public DateOperatorFactory withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null!"); Assert.notNull(timezone, "Timezone must not be null");
return new DateOperatorFactory(fieldReference, expression, dateValue, timezone); return new DateOperatorFactory(fieldReference, expression, dateValue, timezone);
} }
@ -811,7 +811,7 @@ public class DateOperators {
*/ */
public DateFromPartsOperatorFactory withTimezone(Timezone timezone) { public DateFromPartsOperatorFactory withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null!"); Assert.notNull(timezone, "Timezone must not be null");
return new DateFromPartsOperatorFactory(timezone); return new DateFromPartsOperatorFactory(timezone);
} }
} }
@ -893,7 +893,7 @@ public class DateOperators {
*/ */
public static DayOfYear dayOfYear(Object value) { public static DayOfYear dayOfYear(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new DayOfYear(value); return new DayOfYear(value);
} }
@ -905,7 +905,7 @@ public class DateOperators {
*/ */
public static DayOfYear dayOfYear(String fieldReference) { public static DayOfYear dayOfYear(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return dayOfYear(Fields.field(fieldReference)); return dayOfYear(Fields.field(fieldReference));
} }
@ -917,7 +917,7 @@ public class DateOperators {
*/ */
public static DayOfYear dayOfYear(AggregationExpression expression) { public static DayOfYear dayOfYear(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return dayOfYear((Object) expression); return dayOfYear((Object) expression);
} }
@ -933,7 +933,7 @@ public class DateOperators {
@Override @Override
public DayOfYear withTimezone(Timezone timezone) { public DayOfYear withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new DayOfYear(appendTimezone(values().iterator().next(), timezone)); return new DayOfYear(appendTimezone(values().iterator().next(), timezone));
} }
@ -965,7 +965,7 @@ public class DateOperators {
*/ */
public static DayOfMonth dayOfMonth(Object value) { public static DayOfMonth dayOfMonth(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new DayOfMonth(value); return new DayOfMonth(value);
} }
@ -977,7 +977,7 @@ public class DateOperators {
*/ */
public static DayOfMonth dayOfMonth(String fieldReference) { public static DayOfMonth dayOfMonth(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return dayOfMonth(Fields.field(fieldReference)); return dayOfMonth(Fields.field(fieldReference));
} }
@ -989,7 +989,7 @@ public class DateOperators {
*/ */
public static DayOfMonth dayOfMonth(AggregationExpression expression) { public static DayOfMonth dayOfMonth(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return dayOfMonth((Object) expression); return dayOfMonth((Object) expression);
} }
@ -1005,7 +1005,7 @@ public class DateOperators {
@Override @Override
public DayOfMonth withTimezone(Timezone timezone) { public DayOfMonth withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new DayOfMonth(appendTimezone(values().iterator().next(), timezone)); return new DayOfMonth(appendTimezone(values().iterator().next(), timezone));
} }
@ -1037,7 +1037,7 @@ public class DateOperators {
*/ */
public static DayOfWeek dayOfWeek(Object value) { public static DayOfWeek dayOfWeek(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new DayOfWeek(value); return new DayOfWeek(value);
} }
@ -1049,7 +1049,7 @@ public class DateOperators {
*/ */
public static DayOfWeek dayOfWeek(String fieldReference) { public static DayOfWeek dayOfWeek(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return dayOfWeek(Fields.field(fieldReference)); return dayOfWeek(Fields.field(fieldReference));
} }
@ -1061,7 +1061,7 @@ public class DateOperators {
*/ */
public static DayOfWeek dayOfWeek(AggregationExpression expression) { public static DayOfWeek dayOfWeek(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return dayOfWeek((Object) expression); return dayOfWeek((Object) expression);
} }
@ -1077,7 +1077,7 @@ public class DateOperators {
@Override @Override
public DayOfWeek withTimezone(Timezone timezone) { public DayOfWeek withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new DayOfWeek(appendTimezone(values().iterator().next(), timezone)); return new DayOfWeek(appendTimezone(values().iterator().next(), timezone));
} }
@ -1109,7 +1109,7 @@ public class DateOperators {
*/ */
public static Year year(Object value) { public static Year year(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Year(value); return new Year(value);
} }
@ -1121,7 +1121,7 @@ public class DateOperators {
*/ */
public static Year yearOf(String fieldReference) { public static Year yearOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return year(Fields.field(fieldReference)); return year(Fields.field(fieldReference));
} }
@ -1133,7 +1133,7 @@ public class DateOperators {
*/ */
public static Year yearOf(AggregationExpression expression) { public static Year yearOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return year(expression); return year(expression);
} }
@ -1149,7 +1149,7 @@ public class DateOperators {
@Override @Override
public Year withTimezone(Timezone timezone) { public Year withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Year(appendTimezone(values().iterator().next(), timezone)); return new Year(appendTimezone(values().iterator().next(), timezone));
} }
@ -1181,7 +1181,7 @@ public class DateOperators {
*/ */
public static Month month(Object value) { public static Month month(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Month(value); return new Month(value);
} }
@ -1193,7 +1193,7 @@ public class DateOperators {
*/ */
public static Month monthOf(String fieldReference) { public static Month monthOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return month(Fields.field(fieldReference)); return month(Fields.field(fieldReference));
} }
@ -1205,7 +1205,7 @@ public class DateOperators {
*/ */
public static Month monthOf(AggregationExpression expression) { public static Month monthOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return month(expression); return month(expression);
} }
@ -1221,7 +1221,7 @@ public class DateOperators {
@Override @Override
public Month withTimezone(Timezone timezone) { public Month withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Month(appendTimezone(values().iterator().next(), timezone)); return new Month(appendTimezone(values().iterator().next(), timezone));
} }
@ -1253,7 +1253,7 @@ public class DateOperators {
*/ */
public static Week week(Object value) { public static Week week(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Week(value); return new Week(value);
} }
@ -1265,7 +1265,7 @@ public class DateOperators {
*/ */
public static Week weekOf(String fieldReference) { public static Week weekOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return week(Fields.field(fieldReference)); return week(Fields.field(fieldReference));
} }
@ -1277,7 +1277,7 @@ public class DateOperators {
*/ */
public static Week weekOf(AggregationExpression expression) { public static Week weekOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return week(expression); return week(expression);
} }
@ -1293,7 +1293,7 @@ public class DateOperators {
@Override @Override
public Week withTimezone(Timezone timezone) { public Week withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Week(appendTimezone(values().iterator().next(), timezone)); return new Week(appendTimezone(values().iterator().next(), timezone));
} }
@ -1325,7 +1325,7 @@ public class DateOperators {
*/ */
public static Hour hour(Object value) { public static Hour hour(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Hour(value); return new Hour(value);
} }
@ -1337,7 +1337,7 @@ public class DateOperators {
*/ */
public static Hour hourOf(String fieldReference) { public static Hour hourOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return hour(Fields.field(fieldReference)); return hour(Fields.field(fieldReference));
} }
@ -1349,7 +1349,7 @@ public class DateOperators {
*/ */
public static Hour hourOf(AggregationExpression expression) { public static Hour hourOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return hour(expression); return hour(expression);
} }
@ -1365,7 +1365,7 @@ public class DateOperators {
@Override @Override
public Hour withTimezone(Timezone timezone) { public Hour withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Hour(appendTimezone(values().iterator().next(), timezone)); return new Hour(appendTimezone(values().iterator().next(), timezone));
} }
@ -1397,7 +1397,7 @@ public class DateOperators {
*/ */
public static Minute minute(Object value) { public static Minute minute(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Minute(value); return new Minute(value);
} }
@ -1409,7 +1409,7 @@ public class DateOperators {
*/ */
public static Minute minuteOf(String fieldReference) { public static Minute minuteOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return minute(Fields.field(fieldReference)); return minute(Fields.field(fieldReference));
} }
@ -1421,7 +1421,7 @@ public class DateOperators {
*/ */
public static Minute minuteOf(AggregationExpression expression) { public static Minute minuteOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return minute(expression); return minute(expression);
} }
@ -1437,7 +1437,7 @@ public class DateOperators {
@Override @Override
public Minute withTimezone(Timezone timezone) { public Minute withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Minute(appendTimezone(values().iterator().next(), timezone)); return new Minute(appendTimezone(values().iterator().next(), timezone));
} }
@ -1469,7 +1469,7 @@ public class DateOperators {
*/ */
public static Second second(Object value) { public static Second second(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Second(value); return new Second(value);
} }
@ -1481,7 +1481,7 @@ public class DateOperators {
*/ */
public static Second secondOf(String fieldReference) { public static Second secondOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return second(Fields.field(fieldReference)); return second(Fields.field(fieldReference));
} }
@ -1493,7 +1493,7 @@ public class DateOperators {
*/ */
public static Second secondOf(AggregationExpression expression) { public static Second secondOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return second(expression); return second(expression);
} }
@ -1509,7 +1509,7 @@ public class DateOperators {
@Override @Override
public Second withTimezone(Timezone timezone) { public Second withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Second(appendTimezone(values().iterator().next(), timezone)); return new Second(appendTimezone(values().iterator().next(), timezone));
} }
@ -1541,7 +1541,7 @@ public class DateOperators {
*/ */
public static Millisecond millisecond(Object value) { public static Millisecond millisecond(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new Millisecond(value); return new Millisecond(value);
} }
@ -1553,7 +1553,7 @@ public class DateOperators {
*/ */
public static Millisecond millisecondOf(String fieldReference) { public static Millisecond millisecondOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return millisecond(Fields.field(fieldReference)); return millisecond(Fields.field(fieldReference));
} }
@ -1565,7 +1565,7 @@ public class DateOperators {
*/ */
public static Millisecond millisecondOf(AggregationExpression expression) { public static Millisecond millisecondOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return millisecond(expression); return millisecond(expression);
} }
@ -1581,7 +1581,7 @@ public class DateOperators {
@Override @Override
public Millisecond withTimezone(Timezone timezone) { public Millisecond withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new Millisecond(appendTimezone(values().iterator().next(), timezone)); return new Millisecond(appendTimezone(values().iterator().next(), timezone));
} }
@ -1613,14 +1613,14 @@ public class DateOperators {
*/ */
public static FormatBuilder dateToString(Object value) { public static FormatBuilder dateToString(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new FormatBuilder() { return new FormatBuilder() {
@Override @Override
public DateToString toString(String format) { public DateToString toString(String format) {
Assert.notNull(format, "Format must not be null!"); Assert.notNull(format, "Format must not be null");
return new DateToString(argumentMap(value, format, Timezone.none())); return new DateToString(argumentMap(value, format, Timezone.none()));
} }
@ -1639,7 +1639,7 @@ public class DateOperators {
*/ */
public static FormatBuilder dateOf(final String fieldReference) { public static FormatBuilder dateOf(final String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return dateToString(Fields.field(fieldReference)); return dateToString(Fields.field(fieldReference));
} }
@ -1651,7 +1651,7 @@ public class DateOperators {
*/ */
public static FormatBuilder dateOf(final AggregationExpression expression) { public static FormatBuilder dateOf(final AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return dateToString(expression); return dateToString(expression);
} }
@ -1667,7 +1667,7 @@ public class DateOperators {
@Override @Override
public DateToString withTimezone(Timezone timezone) { public DateToString withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new DateToString(append("timezone", timezone)); return new DateToString(append("timezone", timezone));
} }
@ -1790,7 +1790,7 @@ public class DateOperators {
*/ */
public static IsoDayOfWeek isoDayWeek(Object value) { public static IsoDayOfWeek isoDayWeek(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new IsoDayOfWeek(value); return new IsoDayOfWeek(value);
} }
@ -1802,7 +1802,7 @@ public class DateOperators {
*/ */
public static IsoDayOfWeek isoDayOfWeek(String fieldReference) { public static IsoDayOfWeek isoDayOfWeek(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return isoDayWeek(Fields.field(fieldReference)); return isoDayWeek(Fields.field(fieldReference));
} }
@ -1814,7 +1814,7 @@ public class DateOperators {
*/ */
public static IsoDayOfWeek isoDayOfWeek(AggregationExpression expression) { public static IsoDayOfWeek isoDayOfWeek(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return isoDayWeek(expression); return isoDayWeek(expression);
} }
@ -1830,7 +1830,7 @@ public class DateOperators {
@Override @Override
public IsoDayOfWeek withTimezone(Timezone timezone) { public IsoDayOfWeek withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new IsoDayOfWeek(appendTimezone(values().iterator().next(), timezone)); return new IsoDayOfWeek(appendTimezone(values().iterator().next(), timezone));
} }
@ -1862,7 +1862,7 @@ public class DateOperators {
*/ */
public static IsoWeek isoWeek(Object value) { public static IsoWeek isoWeek(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new IsoWeek(value); return new IsoWeek(value);
} }
@ -1874,7 +1874,7 @@ public class DateOperators {
*/ */
public static IsoWeek isoWeekOf(String fieldReference) { public static IsoWeek isoWeekOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return isoWeek(Fields.field(fieldReference)); return isoWeek(Fields.field(fieldReference));
} }
@ -1886,7 +1886,7 @@ public class DateOperators {
*/ */
public static IsoWeek isoWeekOf(AggregationExpression expression) { public static IsoWeek isoWeekOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return isoWeek(expression); return isoWeek(expression);
} }
@ -1902,7 +1902,7 @@ public class DateOperators {
@Override @Override
public IsoWeek withTimezone(Timezone timezone) { public IsoWeek withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new IsoWeek(appendTimezone(values().iterator().next(), timezone)); return new IsoWeek(appendTimezone(values().iterator().next(), timezone));
} }
@ -1934,7 +1934,7 @@ public class DateOperators {
*/ */
public static IsoWeekYear isoWeekYear(Object value) { public static IsoWeekYear isoWeekYear(Object value) {
Assert.notNull(value, "value must not be null!"); Assert.notNull(value, "value must not be null");
return new IsoWeekYear(value); return new IsoWeekYear(value);
} }
@ -1946,7 +1946,7 @@ public class DateOperators {
*/ */
public static IsoWeekYear isoWeekYearOf(String fieldReference) { public static IsoWeekYear isoWeekYearOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return isoWeekYear(Fields.field(fieldReference)); return isoWeekYear(Fields.field(fieldReference));
} }
@ -1958,7 +1958,7 @@ public class DateOperators {
*/ */
public static IsoWeekYear isoWeekYearOf(AggregationExpression expression) { public static IsoWeekYear isoWeekYearOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return isoWeekYear(expression); return isoWeekYear(expression);
} }
@ -1974,7 +1974,7 @@ public class DateOperators {
@Override @Override
public IsoWeekYear withTimezone(Timezone timezone) { public IsoWeekYear withTimezone(Timezone timezone) {
Assert.notNull(timezone, "Timezone must not be null."); Assert.notNull(timezone, "Timezone must not be null");
return new IsoWeekYear(appendTimezone(values().iterator().next(), timezone)); return new IsoWeekYear(appendTimezone(values().iterator().next(), timezone));
} }
@ -2278,7 +2278,7 @@ public class DateOperators {
*/ */
default DateFromParts yearOf(String fieldReference) { default DateFromParts yearOf(String fieldReference) {
Assert.hasText(fieldReference, "Field reference must not be null nor empty."); Assert.hasText(fieldReference, "Field reference must not be null nor empty");
return year(Fields.field(fieldReference)); return year(Fields.field(fieldReference));
} }
@ -2291,7 +2291,7 @@ public class DateOperators {
*/ */
default DateFromParts yearOf(AggregationExpression expression) { default DateFromParts yearOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return year(expression); return year(expression);
} }
} }
@ -2454,7 +2454,7 @@ public class DateOperators {
*/ */
default IsoDateFromParts isoWeekYearOf(String fieldReference) { default IsoDateFromParts isoWeekYearOf(String fieldReference) {
Assert.hasText(fieldReference, "Field reference must not be null nor empty."); Assert.hasText(fieldReference, "Field reference must not be null nor empty");
return isoWeekYear(Fields.field(fieldReference)); return isoWeekYear(Fields.field(fieldReference));
} }
@ -2467,7 +2467,7 @@ public class DateOperators {
*/ */
default IsoDateFromParts isoWeekYearOf(AggregationExpression expression) { default IsoDateFromParts isoWeekYearOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return isoWeekYear(expression); return isoWeekYear(expression);
} }
} }
@ -2498,7 +2498,7 @@ public class DateOperators {
*/ */
public static DateToParts dateToParts(Object value) { public static DateToParts dateToParts(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new DateToParts(Collections.singletonMap("date", value)); return new DateToParts(Collections.singletonMap("date", value));
} }
@ -2511,7 +2511,7 @@ public class DateOperators {
*/ */
public static DateToParts datePartsOf(String fieldReference) { public static DateToParts datePartsOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return dateToParts(Fields.field(fieldReference)); return dateToParts(Fields.field(fieldReference));
} }
@ -2626,7 +2626,7 @@ public class DateOperators {
*/ */
public DateFromString withFormat(String format) { public DateFromString withFormat(String format) {
Assert.notNull(format, "Format must not be null!"); Assert.notNull(format, "Format must not be null");
return new DateFromString(append("format", format)); return new DateFromString(append("format", format));
} }

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

@ -93,7 +93,7 @@ abstract class DocumentEnhancingOperation implements InheritsFieldsAggregationOp
return exposedFields.and(new ExposedField(Fields.field((String) field), true)); return exposedFields.and(new ExposedField(Fields.field((String) field), true));
} }
throw new IllegalArgumentException(String.format("Expected %s to be a field/property.", field)); throw new IllegalArgumentException(String.format("Expected %s to be a field/property", field));
} }
private static Document toSetEntry(Entry<Object, Object> entry, AggregationOperationContext context) { private static Document toSetEntry(Entry<Object, Object> entry, AggregationOperationContext context) {
@ -148,8 +148,8 @@ abstract class DocumentEnhancingOperation implements InheritsFieldsAggregationOp
*/ */
ExpressionProjection(String expression, Object[] parameters) { ExpressionProjection(String expression, Object[] parameters) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
Assert.notNull(parameters, "Parameters must not be null!"); Assert.notNull(parameters, "Parameters must not be null");
this.expression = expression; this.expression = expression;
this.params = parameters.clone(); this.params = parameters.clone();

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

@ -60,7 +60,7 @@ public class EvaluationOperators {
*/ */
public EvaluationOperatorFactory(String fieldReference) { public EvaluationOperatorFactory(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
this.fieldReference = fieldReference; this.fieldReference = fieldReference;
this.expression = null; this.expression = null;
} }
@ -72,7 +72,7 @@ public class EvaluationOperators {
*/ */
public EvaluationOperatorFactory(AggregationExpression expression) { public EvaluationOperatorFactory(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.fieldReference = null; this.fieldReference = null;
this.expression = expression; this.expression = expression;
} }
@ -108,7 +108,7 @@ public class EvaluationOperators {
*/ */
public static Expr valueOf(String fieldReference) { public static Expr valueOf(String fieldReference) {
Assert.notNull(fieldReference, "FieldReference must not be null!"); Assert.notNull(fieldReference, "FieldReference must not be null");
return new Expr(Fields.field(fieldReference)); return new Expr(Fields.field(fieldReference));
} }
@ -120,7 +120,7 @@ public class EvaluationOperators {
*/ */
public static Expr valueOf(AggregationExpression expression) { public static Expr valueOf(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return new Expr(expression); return new Expr(expression);
} }

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

@ -109,7 +109,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
*/ */
private static ExposedFields createFields(Fields fields, boolean synthetic) { private static ExposedFields createFields(Fields fields, boolean synthetic) {
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
List<ExposedField> result = new ArrayList<ExposedField>(); List<ExposedField> result = new ArrayList<ExposedField>();
for (Field field : fields) { for (Field field : fields) {
@ -139,7 +139,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
*/ */
public ExposedFields and(ExposedField field) { public ExposedFields and(ExposedField field) {
Assert.notNull(field, "Exposed field must not be null!"); Assert.notNull(field, "Exposed field must not be null");
ArrayList<ExposedField> result = new ArrayList<ExposedField>(); ArrayList<ExposedField> result = new ArrayList<ExposedField>();
result.addAll(field.synthetic ? syntheticFields : originalFields); result.addAll(field.synthetic ? syntheticFields : originalFields);
@ -361,7 +361,7 @@ public final class ExposedFields implements Iterable<ExposedField> {
*/ */
public DirectFieldReference(ExposedField field) { public DirectFieldReference(ExposedField field) {
Assert.notNull(field, "ExposedField must not be null!"); Assert.notNull(field, "ExposedField must not be null");
this.field = field; this.field = field;
} }

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

@ -47,8 +47,8 @@ class ExposedFieldsAggregationOperationContext implements AggregationOperationCo
public ExposedFieldsAggregationOperationContext(ExposedFields exposedFields, public ExposedFieldsAggregationOperationContext(ExposedFields exposedFields,
AggregationOperationContext rootContext) { AggregationOperationContext rootContext) {
Assert.notNull(exposedFields, "ExposedFields must not be null!"); Assert.notNull(exposedFields, "ExposedFields must not be null");
Assert.notNull(rootContext, "RootContext must not be null!"); Assert.notNull(rootContext, "RootContext must not be null");
this.exposedFields = exposedFields; this.exposedFields = exposedFields;
this.rootContext = rootContext; this.rootContext = rootContext;
@ -88,14 +88,14 @@ class ExposedFieldsAggregationOperationContext implements AggregationOperationCo
*/ */
private FieldReference getReference(@Nullable Field field, String name) { private FieldReference getReference(@Nullable Field field, String name) {
Assert.notNull(name, "Name must not be null!"); Assert.notNull(name, "Name must not be null");
FieldReference exposedField = resolveExposedField(field, name); FieldReference exposedField = resolveExposedField(field, name);
if (exposedField != null) { if (exposedField != null) {
return exposedField; return exposedField;
} }
throw new IllegalArgumentException(String.format("Invalid reference '%s'!", name)); throw new IllegalArgumentException(String.format("Invalid reference '%s'", name));
} }
/** /**

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

@ -72,8 +72,8 @@ public class FacetOperation implements FieldsExposingAggregationOperation {
*/ */
public FacetOperationBuilder and(AggregationOperation... operations) { public FacetOperationBuilder and(AggregationOperation... operations) {
Assert.notNull(operations, "AggregationOperations must not be null!"); Assert.notNull(operations, "AggregationOperations must not be null");
Assert.notEmpty(operations, "AggregationOperations must not be empty!"); Assert.notEmpty(operations, "AggregationOperations must not be empty");
return new FacetOperationBuilder(facets, Arrays.asList(operations)); return new FacetOperationBuilder(facets, Arrays.asList(operations));
} }
@ -118,7 +118,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation {
*/ */
public FacetOperation as(String fieldName) { public FacetOperation as(String fieldName) {
Assert.hasText(fieldName, "FieldName must not be null or empty!"); Assert.hasText(fieldName, "FieldName must not be null or empty");
return new FacetOperation(current.and(fieldName, operations)); return new FacetOperation(current.and(fieldName, operations));
} }
@ -178,8 +178,8 @@ public class FacetOperation implements FieldsExposingAggregationOperation {
*/ */
Facets and(String fieldName, List<AggregationOperation> operations) { Facets and(String fieldName, List<AggregationOperation> operations) {
Assert.hasText(fieldName, "FieldName must not be null or empty!"); Assert.hasText(fieldName, "FieldName must not be null or empty");
Assert.notNull(operations, "AggregationOperations must not be null!"); Assert.notNull(operations, "AggregationOperations must not be null");
List<Facet> facets = new ArrayList<Facet>(this.facets.size() + 1); List<Facet> facets = new ArrayList<Facet>(this.facets.size() + 1);
facets.addAll(this.facets); facets.addAll(this.facets);
@ -207,8 +207,8 @@ public class FacetOperation implements FieldsExposingAggregationOperation {
*/ */
Facet(ExposedField exposedField, List<AggregationOperation> operations) { Facet(ExposedField exposedField, List<AggregationOperation> operations) {
Assert.notNull(exposedField, "ExposedField must not be null!"); Assert.notNull(exposedField, "ExposedField must not be null");
Assert.notNull(operations, "AggregationOperations must not be null!"); Assert.notNull(operations, "AggregationOperations must not be null");
this.exposedField = exposedField; this.exposedField = exposedField;
this.operations = operations; this.operations = operations;

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

@ -37,8 +37,8 @@ import org.springframework.util.StringUtils;
*/ */
public final class Fields implements Iterable<Field> { public final class Fields implements Iterable<Field> {
private static final String AMBIGUOUS_EXCEPTION = "Found two fields both using '%s' as name: %s and %s! Please " private static final String AMBIGUOUS_EXCEPTION = "Found two fields both using '%s' as name: %s and %s; Please "
+ "customize your field definitions to get to unique field names!"; + "customize your field definitions to get to unique field names";
public static final String UNDERSCORE_ID = "_id"; public static final String UNDERSCORE_ID = "_id";
public static final String UNDERSCORE_ID_REF = "$_id"; public static final String UNDERSCORE_ID_REF = "$_id";
@ -53,7 +53,7 @@ public final class Fields implements Iterable<Field> {
*/ */
public static Fields from(Field... fields) { public static Fields from(Field... fields) {
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
return new Fields(Arrays.asList(fields)); return new Fields(Arrays.asList(fields));
} }
@ -65,7 +65,7 @@ public final class Fields implements Iterable<Field> {
*/ */
public static Fields fields(String... names) { public static Fields fields(String... names) {
Assert.notNull(names, "Field names must not be null!"); Assert.notNull(names, "Field names must not be null");
List<Field> fields = new ArrayList<Field>(); List<Field> fields = new ArrayList<Field>();
@ -96,7 +96,7 @@ public final class Fields implements Iterable<Field> {
* @return * @return
*/ */
public static Field field(String name, String target) { public static Field field(String name, String target) {
Assert.hasText(target, "Target must not be null or empty!"); Assert.hasText(target, "Target must not be null or empty");
return new AggregationField(name, target); return new AggregationField(name, target);
} }
@ -107,7 +107,7 @@ public final class Fields implements Iterable<Field> {
*/ */
private Fields(List<Field> fields) { private Fields(List<Field> fields) {
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
this.fields = verify(fields); this.fields = verify(fields);
} }
@ -228,7 +228,7 @@ public final class Fields implements Iterable<Field> {
String nameToSet = name != null ? cleanUp(name) : null; String nameToSet = name != null ? cleanUp(name) : null;
String targetToSet = target != null ? cleanUp(target) : null; String targetToSet = target != null ? cleanUp(target) : null;
Assert.hasText(nameToSet, "AggregationField name must not be null or empty!"); Assert.hasText(nameToSet, "AggregationField name must not be null or empty");
if (target == null && name.contains(".")) { if (target == null && name.contains(".")) {
this.name = nameToSet.substring(nameToSet.indexOf('.') + 1); this.name = nameToSet.substring(nameToSet.indexOf('.') + 1);

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

@ -64,8 +64,8 @@ public class GeoNearOperation implements AggregationOperation {
*/ */
private GeoNearOperation(NearQuery nearQuery, String distanceField, @Nullable String indexKey) { private GeoNearOperation(NearQuery nearQuery, String distanceField, @Nullable String indexKey) {
Assert.notNull(nearQuery, "NearQuery must not be null."); Assert.notNull(nearQuery, "NearQuery must not be null");
Assert.hasLength(distanceField, "Distance field must not be null or empty."); Assert.hasLength(distanceField, "Distance field must not be null or empty");
this.nearQuery = nearQuery; this.nearQuery = nearQuery;
this.distanceField = distanceField; this.distanceField = distanceField;

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

@ -225,7 +225,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public StartWithBuilder from(String collectionName) { public StartWithBuilder from(String collectionName) {
Assert.hasText(collectionName, "CollectionName must not be null or empty!"); Assert.hasText(collectionName, "CollectionName must not be null or empty");
this.from = collectionName; this.from = collectionName;
return this; return this;
@ -234,8 +234,8 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public ConnectFromBuilder startWith(String... fieldReferences) { public ConnectFromBuilder startWith(String... fieldReferences) {
Assert.notNull(fieldReferences, "FieldReferences must not be null!"); Assert.notNull(fieldReferences, "FieldReferences must not be null");
Assert.noNullElements(fieldReferences, "FieldReferences must not contain null elements!"); Assert.noNullElements(fieldReferences, "FieldReferences must not contain null elements");
List<Object> fields = new ArrayList<Object>(fieldReferences.length); List<Object> fields = new ArrayList<Object>(fieldReferences.length);
@ -250,8 +250,8 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public ConnectFromBuilder startWith(AggregationExpression... expressions) { public ConnectFromBuilder startWith(AggregationExpression... expressions) {
Assert.notNull(expressions, "AggregationExpressions must not be null!"); Assert.notNull(expressions, "AggregationExpressions must not be null");
Assert.noNullElements(expressions, "AggregationExpressions must not contain null elements!"); Assert.noNullElements(expressions, "AggregationExpressions must not contain null elements");
this.startWith = Arrays.asList(expressions); this.startWith = Arrays.asList(expressions);
return this; return this;
@ -260,8 +260,8 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public ConnectFromBuilder startWith(Object... expressions) { public ConnectFromBuilder startWith(Object... expressions) {
Assert.notNull(expressions, "Expressions must not be null!"); Assert.notNull(expressions, "Expressions must not be null");
Assert.noNullElements(expressions, "Expressions must not contain null elements!"); Assert.noNullElements(expressions, "Expressions must not contain null elements");
this.startWith = verifyAndPotentiallyTransformStartsWithTypes(expressions); this.startWith = verifyAndPotentiallyTransformStartsWithTypes(expressions);
return this; return this;
@ -301,7 +301,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public ConnectToBuilder connectFrom(String fieldName) { public ConnectToBuilder connectFrom(String fieldName) {
Assert.hasText(fieldName, "ConnectFrom must not be null or empty!"); Assert.hasText(fieldName, "ConnectFrom must not be null or empty");
this.connectFrom = fieldName; this.connectFrom = fieldName;
return this; return this;
@ -310,7 +310,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
@Override @Override
public GraphLookupOperationBuilder connectTo(String fieldName) { public GraphLookupOperationBuilder connectTo(String fieldName) {
Assert.hasText(fieldName, "ConnectTo must not be null or empty!"); Assert.hasText(fieldName, "ConnectTo must not be null or empty");
return new GraphLookupOperationBuilder(from, startWith, connectFrom, fieldName); return new GraphLookupOperationBuilder(from, startWith, connectFrom, fieldName);
} }
@ -346,7 +346,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
*/ */
public GraphLookupOperationBuilder maxDepth(long numberOfRecursions) { public GraphLookupOperationBuilder maxDepth(long numberOfRecursions) {
Assert.isTrue(numberOfRecursions >= 0, "Max depth must be >= 0!"); Assert.isTrue(numberOfRecursions >= 0, "Max depth must be >= 0");
this.maxDepth = numberOfRecursions; this.maxDepth = numberOfRecursions;
return this; return this;
@ -360,7 +360,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
*/ */
public GraphLookupOperationBuilder depthField(String fieldName) { public GraphLookupOperationBuilder depthField(String fieldName) {
Assert.hasText(fieldName, "Depth field name must not be null or empty!"); Assert.hasText(fieldName, "Depth field name must not be null or empty");
this.depthField = Fields.field(fieldName); this.depthField = Fields.field(fieldName);
return this; return this;
@ -374,7 +374,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
*/ */
public GraphLookupOperationBuilder restrict(CriteriaDefinition criteriaDefinition) { public GraphLookupOperationBuilder restrict(CriteriaDefinition criteriaDefinition) {
Assert.notNull(criteriaDefinition, "CriteriaDefinition must not be null!"); Assert.notNull(criteriaDefinition, "CriteriaDefinition must not be null");
this.restrictSearchWithMatch = criteriaDefinition; this.restrictSearchWithMatch = criteriaDefinition;
return this; return this;
@ -389,7 +389,7 @@ public class GraphLookupOperation implements InheritsFieldsAggregationOperation
*/ */
public GraphLookupOperation as(String fieldName) { public GraphLookupOperation as(String fieldName) {
Assert.hasText(fieldName, "As field name must not be null or empty!"); Assert.hasText(fieldName, "As field name must not be null or empty");
return new GraphLookupOperation(from, startWith, connectFrom, connectTo, Fields.field(fieldName), maxDepth, return new GraphLookupOperation(from, startWith, connectFrom, connectTo, Fields.field(fieldName), maxDepth,
depthField, restrictSearchWithMatch); depthField, restrictSearchWithMatch);

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

@ -80,8 +80,8 @@ public class GroupOperation implements FieldsExposingAggregationOperation {
*/ */
private GroupOperation(GroupOperation groupOperation, List<Operation> nextOperations) { private GroupOperation(GroupOperation groupOperation, List<Operation> nextOperations) {
Assert.notNull(groupOperation, "GroupOperation must not be null!"); Assert.notNull(groupOperation, "GroupOperation must not be null");
Assert.notNull(nextOperations, "NextOperations must not be null!"); Assert.notNull(nextOperations, "NextOperations must not be null");
this.idFields = groupOperation.idFields; this.idFields = groupOperation.idFields;
this.operations = new ArrayList<Operation>(nextOperations.size() + 1); this.operations = new ArrayList<Operation>(nextOperations.size() + 1);
@ -117,8 +117,8 @@ public class GroupOperation implements FieldsExposingAggregationOperation {
*/ */
private GroupOperationBuilder(GroupOperation groupOperation, Operation operation) { private GroupOperationBuilder(GroupOperation groupOperation, Operation operation) {
Assert.notNull(groupOperation, "GroupOperation must not be null!"); Assert.notNull(groupOperation, "GroupOperation must not be null");
Assert.notNull(operation, "Operation must not be null!"); Assert.notNull(operation, "Operation must not be null");
this.groupOperation = groupOperation; this.groupOperation = groupOperation;
this.operation = operation; this.operation = operation;
@ -168,7 +168,7 @@ public class GroupOperation implements FieldsExposingAggregationOperation {
*/ */
public GroupOperationBuilder sum(AggregationExpression expr) { public GroupOperationBuilder sum(AggregationExpression expr) {
Assert.notNull(expr, "Expr must not be null!"); Assert.notNull(expr, "Expr must not be null");
return newBuilder(GroupOps.SUM, null, expr); return newBuilder(GroupOps.SUM, null, expr);
} }

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

@ -39,7 +39,7 @@ public class LimitOperation implements AggregationOperation {
*/ */
public LimitOperation(long maxElements) { public LimitOperation(long maxElements) {
Assert.isTrue(maxElements >= 0, "Maximum number of elements must be greater or equal to zero!"); Assert.isTrue(maxElements >= 0, "Maximum number of elements must be greater or equal to zero");
this.maxElements = maxElements; this.maxElements = maxElements;
} }

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

@ -33,7 +33,7 @@ public class LiteralOperators {
*/ */
public static LiteralOperatorFactory valueOf(Object value) { public static LiteralOperatorFactory valueOf(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new LiteralOperatorFactory(value); return new LiteralOperatorFactory(value);
} }
@ -51,7 +51,7 @@ public class LiteralOperators {
*/ */
public LiteralOperatorFactory(Object value) { public LiteralOperatorFactory(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.value = value; this.value = value;
} }
@ -89,7 +89,7 @@ public class LiteralOperators {
*/ */
public static Literal asLiteral(Object value) { public static Literal asLiteral(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new Literal(value); return new Literal(value);
} }
} }

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

@ -49,10 +49,10 @@ public class LookupOperation implements FieldsExposingAggregationOperation, Inhe
*/ */
public LookupOperation(Field from, Field localField, Field foreignField, Field as) { public LookupOperation(Field from, Field localField, Field foreignField, Field as) {
Assert.notNull(from, "From must not be null!"); Assert.notNull(from, "From must not be null");
Assert.notNull(localField, "LocalField must not be null!"); Assert.notNull(localField, "LocalField must not be null");
Assert.notNull(foreignField, "ForeignField must not be null!"); Assert.notNull(foreignField, "ForeignField must not be null");
Assert.notNull(as, "As must not be null!"); Assert.notNull(as, "As must not be null");
this.from = from; this.from = from;
this.localField = localField; this.localField = localField;
@ -155,7 +155,7 @@ public class LookupOperation implements FieldsExposingAggregationOperation, Inhe
@Override @Override
public LocalFieldBuilder from(String name) { public LocalFieldBuilder from(String name) {
Assert.hasText(name, "'From' must not be null or empty!"); Assert.hasText(name, "'From' must not be null or empty");
from = Fields.field(name); from = Fields.field(name);
return this; return this;
} }
@ -163,7 +163,7 @@ public class LookupOperation implements FieldsExposingAggregationOperation, Inhe
@Override @Override
public LookupOperation as(String name) { public LookupOperation as(String name) {
Assert.hasText(name, "'As' must not be null or empty!"); Assert.hasText(name, "'As' must not be null or empty");
as = new ExposedField(Fields.field(name), true); as = new ExposedField(Fields.field(name), true);
return new LookupOperation(from, localField, foreignField, as); return new LookupOperation(from, localField, foreignField, as);
} }
@ -171,7 +171,7 @@ public class LookupOperation implements FieldsExposingAggregationOperation, Inhe
@Override @Override
public AsBuilder foreignField(String name) { public AsBuilder foreignField(String name) {
Assert.hasText(name, "'ForeignField' must not be null or empty!"); Assert.hasText(name, "'ForeignField' must not be null or empty");
foreignField = Fields.field(name); foreignField = Fields.field(name);
return this; return this;
} }
@ -179,7 +179,7 @@ public class LookupOperation implements FieldsExposingAggregationOperation, Inhe
@Override @Override
public ForeignFieldBuilder localField(String name) { public ForeignFieldBuilder localField(String name) {
Assert.hasText(name, "'LocalField' must not be null or empty!"); Assert.hasText(name, "'LocalField' must not be null or empty");
localField = Fields.field(name); localField = Fields.field(name);
return this; return this;
} }

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

@ -47,7 +47,7 @@ public class MatchOperation implements AggregationOperation {
*/ */
public MatchOperation(CriteriaDefinition criteriaDefinition) { public MatchOperation(CriteriaDefinition criteriaDefinition) {
Assert.notNull(criteriaDefinition, "Criteria must not be null!"); Assert.notNull(criteriaDefinition, "Criteria must not be null");
this.criteriaDefinition = criteriaDefinition; this.criteriaDefinition = criteriaDefinition;
this.expression = null; this.expression = null;
@ -61,7 +61,7 @@ public class MatchOperation implements AggregationOperation {
*/ */
public MatchOperation(AggregationExpression expression) { public MatchOperation(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
this.criteriaDefinition = null; this.criteriaDefinition = null;
this.expression = expression; this.expression = expression;

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

@ -62,8 +62,8 @@ public class MergeOperation implements FieldsExposingAggregationOperation, Inher
public MergeOperation(MergeOperationTarget into, UniqueMergeId on, @Nullable Let let, public MergeOperation(MergeOperationTarget into, UniqueMergeId on, @Nullable Let let,
@Nullable WhenDocumentsMatch whenMatched, @Nullable WhenDocumentsDontMatch whenNotMatched) { @Nullable WhenDocumentsMatch whenMatched, @Nullable WhenDocumentsDontMatch whenNotMatched) {
Assert.notNull(into, "Into must not be null! Please provide a target collection."); Assert.notNull(into, "Into must not be null Please provide a target collection");
Assert.notNull(on, "On must not be null! Use UniqueMergeId.id() instead."); Assert.notNull(on, "On must not be null Use UniqueMergeId.id() instead");
this.into = into; this.into = into;
this.on = on; this.on = on;
@ -167,7 +167,7 @@ public class MergeOperation implements FieldsExposingAggregationOperation, Inher
public static UniqueMergeId ofIdFields(String... fields) { public static UniqueMergeId ofIdFields(String... fields) {
Assert.noNullElements(fields, "Fields must not contain null values!"); Assert.noNullElements(fields, "Fields must not contain null values");
if (ObjectUtils.isEmpty(fields)) { if (ObjectUtils.isEmpty(fields)) {
return id(); return id();
@ -225,7 +225,7 @@ public class MergeOperation implements FieldsExposingAggregationOperation, Inher
private MergeOperationTarget(@Nullable String database, String collection) { private MergeOperationTarget(@Nullable String database, String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
this.database = database; this.database = database;
this.collection = collection; this.collection = collection;
@ -360,7 +360,7 @@ public class MergeOperation implements FieldsExposingAggregationOperation, Inher
private WhenDocumentsDontMatch(String value) { private WhenDocumentsDontMatch(String value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.value = value; this.value = value;
} }
@ -432,7 +432,7 @@ public class MergeOperation implements FieldsExposingAggregationOperation, Inher
*/ */
public MergeOperationBuilder intoCollection(String collection) { public MergeOperationBuilder intoCollection(String collection) {
Assert.hasText(collection, "Collection must not be null nor empty!"); Assert.hasText(collection, "Collection must not be null nor empty");
this.collection = collection; this.collection = collection;
return this; return this;

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

@ -45,7 +45,7 @@ class NestedDelegatingExpressionAggregationOperationContext implements Aggregati
NestedDelegatingExpressionAggregationOperationContext(AggregationOperationContext referenceContext, NestedDelegatingExpressionAggregationOperationContext(AggregationOperationContext referenceContext,
Collection<Field> inners) { Collection<Field> inners) {
Assert.notNull(referenceContext, "Reference context must not be null!"); Assert.notNull(referenceContext, "Reference context must not be null");
this.delegate = referenceContext; this.delegate = referenceContext;
this.inners = inners; this.inners = inners;
} }

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

@ -65,7 +65,7 @@ public class ObjectOperators {
*/ */
public ObjectOperatorFactory(Object value) { public ObjectOperatorFactory(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.value = value; this.value = value;
} }

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

@ -57,7 +57,7 @@ public class OutOperation implements AggregationOperation {
private OutOperation(@Nullable String databaseName, String collectionName, @Nullable Document uniqueKey, private OutOperation(@Nullable String databaseName, String collectionName, @Nullable Document uniqueKey,
@Nullable OutMode mode) { @Nullable OutMode mode) {
Assert.notNull(collectionName, "Collection name must not be null!"); Assert.notNull(collectionName, "Collection name must not be null");
this.databaseName = databaseName; this.databaseName = databaseName;
this.collectionName = collectionName; this.collectionName = collectionName;
@ -128,7 +128,7 @@ public class OutOperation implements AggregationOperation {
*/ */
public OutOperation uniqueKeyOf(Iterable<String> fields) { public OutOperation uniqueKeyOf(Iterable<String> fields) {
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
Document uniqueKey = new Document(); Document uniqueKey = new Document();
fields.forEach(it -> uniqueKey.append(it, 1)); fields.forEach(it -> uniqueKey.append(it, 1));
@ -146,7 +146,7 @@ public class OutOperation implements AggregationOperation {
*/ */
public OutOperation mode(OutMode mode) { public OutOperation mode(OutMode mode) {
Assert.notNull(mode, "Mode must not be null!"); Assert.notNull(mode, "Mode must not be null");
return new OutOperation(databaseName, collectionName, uniqueKey, mode); return new OutOperation(databaseName, collectionName, uniqueKey, mode);
} }
@ -193,7 +193,7 @@ public class OutOperation implements AggregationOperation {
return new Document("$out", collectionName); return new Document("$out", collectionName);
} }
Assert.state(mode != null, "Mode must not be null!"); Assert.state(mode != null, "Mode must not be null");
Document $out = new Document("to", collectionName) // Document $out = new Document("to", collectionName) //
.append("mode", mode.getMongoMode()); .append("mode", mode.getMongoMode());

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

@ -53,8 +53,8 @@ import org.springframework.util.Assert;
public class ProjectionOperation implements FieldsExposingAggregationOperation { public class ProjectionOperation implements FieldsExposingAggregationOperation {
private static final List<Projection> NONE = Collections.emptyList(); private static final List<Projection> NONE = Collections.emptyList();
private static final String EXCLUSION_ERROR = "Exclusion of field %s not allowed. Projections by the mongodb " private static final String EXCLUSION_ERROR = "Exclusion of field %s not allowed; Projections by the mongodb"
+ "aggregation framework only support the exclusion of the %s field!"; + " aggregation framework only support the exclusion of the %s field";
private final List<Projection> projections; private final List<Projection> projections;
@ -93,8 +93,8 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
private ProjectionOperation(List<? extends Projection> current, List<? extends Projection> projections) { private ProjectionOperation(List<? extends Projection> current, List<? extends Projection> projections) {
Assert.notNull(current, "Current projections must not be null!"); Assert.notNull(current, "Current projections must not be null");
Assert.notNull(projections, "Projections must not be null!"); Assert.notNull(projections, "Projections must not be null");
this.projections = new ArrayList<ProjectionOperation.Projection>(current.size() + projections.size()); this.projections = new ArrayList<ProjectionOperation.Projection>(current.size() + projections.size());
this.projections.addAll(current); this.projections.addAll(current);
@ -275,8 +275,8 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public AbstractProjectionOperationBuilder(Object value, ProjectionOperation operation) { public AbstractProjectionOperationBuilder(Object value, ProjectionOperation operation) {
Assert.notNull(value, "value must not be null or empty!"); Assert.notNull(value, "value must not be null or empty");
Assert.notNull(operation, "ProjectionOperation must not be null!"); Assert.notNull(operation, "ProjectionOperation must not be null");
this.value = value; this.value = value;
this.operation = operation; this.operation = operation;
@ -390,8 +390,8 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
super(field); super(field);
Assert.hasText(expression, "Expression must not be null!"); Assert.hasText(expression, "Expression must not be null");
Assert.notNull(parameters, "Parameters must not be null!"); Assert.notNull(parameters, "Parameters must not be null");
this.expression = expression; this.expression = expression;
this.params = parameters.clone(); this.params = parameters.clone();
@ -418,8 +418,8 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public static class ProjectionOperationBuilder extends AbstractProjectionOperationBuilder { public static class ProjectionOperationBuilder extends AbstractProjectionOperationBuilder {
private static final String NUMBER_NOT_NULL = "Number must not be null!"; private static final String NUMBER_NOT_NULL = "Number must not be null";
private static final String FIELD_REFERENCE_NOT_NULL = "Field reference must not be null!"; private static final String FIELD_REFERENCE_NOT_NULL = "Field reference must not be null";
private final @Nullable String name; private final @Nullable String name;
private final @Nullable OperationProjection previousProjection; private final @Nullable OperationProjection previousProjection;
@ -502,14 +502,14 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
@Override @Override
public ProjectionOperation applyCondition(Cond cond) { public ProjectionOperation applyCondition(Cond cond) {
Assert.notNull(cond, "ConditionalOperator must not be null!"); Assert.notNull(cond, "ConditionalOperator must not be null");
return this.operation.and(new ExpressionProjection(Fields.field(getRequiredName()), cond)); return this.operation.and(new ExpressionProjection(Fields.field(getRequiredName()), cond));
} }
@Override @Override
public ProjectionOperation applyCondition(IfNull ifNull) { public ProjectionOperation applyCondition(IfNull ifNull) {
Assert.notNull(ifNull, "IfNullOperator must not be null!"); Assert.notNull(ifNull, "IfNullOperator must not be null");
return this.operation.and(new ExpressionProjection(Fields.field(getRequiredName()), ifNull)); return this.operation.and(new ExpressionProjection(Fields.field(getRequiredName()), ifNull));
} }
@ -533,7 +533,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder plus(String fieldReference) { public ProjectionOperationBuilder plus(String fieldReference) {
Assert.notNull(fieldReference, "Field reference must not be null!"); Assert.notNull(fieldReference, "Field reference must not be null");
return project("add", Fields.field(fieldReference)); return project("add", Fields.field(fieldReference));
} }
@ -545,7 +545,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder minus(Number number) { public ProjectionOperationBuilder minus(Number number) {
Assert.notNull(number, "Number must not be null!"); Assert.notNull(number, "Number must not be null");
return project("subtract", number); return project("subtract", number);
} }
@ -572,7 +572,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder minus(AggregationExpression expression) { public ProjectionOperationBuilder minus(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return project("subtract", expression); return project("subtract", expression);
} }
@ -611,7 +611,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder multiply(AggregationExpression expression) { public ProjectionOperationBuilder multiply(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return project("multiply", expression); return project("multiply", expression);
} }
@ -624,7 +624,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
public ProjectionOperationBuilder divide(Number number) { public ProjectionOperationBuilder divide(Number number) {
Assert.notNull(number, FIELD_REFERENCE_NOT_NULL); Assert.notNull(number, FIELD_REFERENCE_NOT_NULL);
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero");
return project("divide", number); return project("divide", number);
} }
@ -651,7 +651,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder divide(AggregationExpression expression) { public ProjectionOperationBuilder divide(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return project("divide", expression); return project("divide", expression);
} }
@ -665,7 +665,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
public ProjectionOperationBuilder mod(Number number) { public ProjectionOperationBuilder mod(Number number) {
Assert.notNull(number, NUMBER_NOT_NULL); Assert.notNull(number, NUMBER_NOT_NULL);
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero");
return project("mod", number); return project("mod", number);
} }
@ -692,7 +692,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder mod(AggregationExpression expression) { public ProjectionOperationBuilder mod(AggregationExpression expression) {
Assert.notNull(expression, "Expression must not be null!"); Assert.notNull(expression, "Expression must not be null");
return project("mod", expression); return project("mod", expression);
} }
@ -835,7 +835,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder equalsArrays(String... arrays) { public ProjectionOperationBuilder equalsArrays(String... arrays) {
Assert.notEmpty(arrays, "Arrays must not be null or empty!"); Assert.notEmpty(arrays, "Arrays must not be null or empty");
return project("setEquals", Fields.fields(arrays)); return project("setEquals", Fields.fields(arrays));
} }
@ -849,7 +849,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder intersectsArrays(String... arrays) { public ProjectionOperationBuilder intersectsArrays(String... arrays) {
Assert.notEmpty(arrays, "Arrays must not be null or empty!"); Assert.notEmpty(arrays, "Arrays must not be null or empty");
return project("setIntersection", Fields.fields(arrays)); return project("setIntersection", Fields.fields(arrays));
} }
@ -863,7 +863,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder unionArrays(String... arrays) { public ProjectionOperationBuilder unionArrays(String... arrays) {
Assert.notEmpty(arrays, "Arrays must not be null or empty!"); Assert.notEmpty(arrays, "Arrays must not be null or empty");
return project("setUnion", Fields.fields(arrays)); return project("setUnion", Fields.fields(arrays));
} }
@ -877,7 +877,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder differenceToArray(String array) { public ProjectionOperationBuilder differenceToArray(String array) {
Assert.hasText(array, "Array must not be null or empty!"); Assert.hasText(array, "Array must not be null or empty");
return project("setDifference", Fields.fields(array)); return project("setDifference", Fields.fields(array));
} }
@ -891,7 +891,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ProjectionOperationBuilder subsetOfArray(String array) { public ProjectionOperationBuilder subsetOfArray(String array) {
Assert.hasText(array, "Array must not be null or empty!"); Assert.hasText(array, "Array must not be null or empty");
return project("setIsSubset", Fields.fields(array)); return project("setIsSubset", Fields.fields(array));
} }
@ -1270,7 +1270,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
private String getRequiredName() { private String getRequiredName() {
Assert.state(name != null, "Projection field name must not be null!"); Assert.state(name != null, "Projection field name must not be null");
return name; return name;
} }
@ -1368,7 +1368,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public static List<FieldProjection> from(Fields fields, @Nullable Object value) { public static List<FieldProjection> from(Fields fields, @Nullable Object value) {
Assert.notNull(fields, "Fields must not be null!"); Assert.notNull(fields, "Fields must not be null");
List<FieldProjection> projections = new ArrayList<FieldProjection>(); List<FieldProjection> projections = new ArrayList<FieldProjection>();
for (Field field : fields) { for (Field field : fields) {
@ -1437,8 +1437,8 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
super(field); super(field);
Assert.hasText(operation, "Operation must not be null or empty!"); Assert.hasText(operation, "Operation must not be null or empty");
Assert.notNull(values, "Values must not be null!"); Assert.notNull(values, "Values must not be null");
this.field = field; this.field = field;
this.operation = operation; this.operation = operation;
@ -1655,7 +1655,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public Projection(Field field) { public Projection(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
this.field = new ExposedField(field, true); this.field = new ExposedField(field, true);
} }
@ -1759,7 +1759,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ArrayProjectionOperationBuilder and(AggregationExpression expression) { public ArrayProjectionOperationBuilder and(AggregationExpression expression) {
Assert.notNull(expression, "AggregationExpression must not be null!"); Assert.notNull(expression, "AggregationExpression must not be null");
this.projections.add(expression); this.projections.add(expression);
return this; return this;
@ -1773,7 +1773,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation {
*/ */
public ArrayProjectionOperationBuilder and(Field field) { public ArrayProjectionOperationBuilder and(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
this.projections.add(field); this.projections.add(field);
return this; return this;

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

@ -63,7 +63,7 @@ public class RedactOperation implements AggregationOperation {
*/ */
public RedactOperation(AggregationExpression condition) { public RedactOperation(AggregationExpression condition) {
Assert.notNull(condition, "Condition must not be null!"); Assert.notNull(condition, "Condition must not be null");
this.condition = condition; this.condition = condition;
} }
@ -237,7 +237,7 @@ public class RedactOperation implements AggregationOperation {
} }
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"Invalid Condition. Expected CriteriaDefinition, AggregationExpression or Document but was %s.", when)); "Invalid Condition; Expected CriteriaDefinition, AggregationExpression or Document but was %s", when));
} }
} }
} }

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

@ -66,7 +66,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
public ReplaceRootOperation(Replacement replacement) { public ReplaceRootOperation(Replacement replacement) {
Assert.notNull(replacement, "Replacement must not be null!"); Assert.notNull(replacement, "Replacement must not be null");
this.replacement = replacement; this.replacement = replacement;
} }
@ -152,7 +152,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
public ReplaceRootOperation withDocument(Document document) { public ReplaceRootOperation withDocument(Document document) {
Assert.notNull(document, "Document must not be null!"); Assert.notNull(document, "Document must not be null");
return new ReplaceRootDocumentOperation().andValuesOf(document); return new ReplaceRootDocumentOperation().andValuesOf(document);
} }
@ -240,8 +240,8 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
protected ReplaceRootDocumentOperationBuilder(ReplaceRootDocumentOperation currentOperation, Object value) { protected ReplaceRootDocumentOperationBuilder(ReplaceRootDocumentOperation currentOperation, Object value) {
Assert.notNull(currentOperation, "Current ReplaceRootDocumentOperation must not be null!"); Assert.notNull(currentOperation, "Current ReplaceRootDocumentOperation must not be null");
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.currentOperation = currentOperation; this.currentOperation = currentOperation;
this.value = value; this.value = value;
@ -287,7 +287,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
protected AggregationExpressionReplacement(AggregationExpression aggregationExpression) { protected AggregationExpressionReplacement(AggregationExpression aggregationExpression) {
Assert.notNull(aggregationExpression, "AggregationExpression must not be null!"); Assert.notNull(aggregationExpression, "AggregationExpression must not be null");
this.aggregationExpression = aggregationExpression; this.aggregationExpression = aggregationExpression;
} }
@ -311,7 +311,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
protected FieldReplacement(Field field) { protected FieldReplacement(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
this.field = field; this.field = field;
} }
@ -344,7 +344,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
protected ReplacementDocument(ReplacementContributor contributor) { protected ReplacementDocument(ReplacementContributor contributor) {
Assert.notNull(contributor, "ReplacementContributor must not be null!"); Assert.notNull(contributor, "ReplacementContributor must not be null");
replacements = Collections.singleton(contributor); replacements = Collections.singleton(contributor);
} }
@ -452,7 +452,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
public DocumentContributor(Object value) { public DocumentContributor(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.value = value; this.value = value;
} }
@ -482,7 +482,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
*/ */
public FieldContributorSupport(Field field) { public FieldContributorSupport(Field field) {
Assert.notNull(field, "Field must not be null!"); Assert.notNull(field, "Field must not be null");
this.field = new ExposedField(field, true); this.field = new ExposedField(field, true);
} }
@ -514,7 +514,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
super(field); super(field);
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
this.value = value; this.value = value;
} }
@ -547,7 +547,7 @@ public class ReplaceRootOperation implements FieldsExposingAggregationOperation
super(field); super(field);
Assert.notNull(aggregationExpression, "AggregationExpression must not be null!"); Assert.notNull(aggregationExpression, "AggregationExpression must not be null");
this.aggregationExpression = aggregationExpression; this.aggregationExpression = aggregationExpression;
} }

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

@ -61,7 +61,7 @@ public class ReplaceWithOperation extends ReplaceRootOperation {
*/ */
public static ReplaceWithOperation replaceWithValueOf(Object value) { public static ReplaceWithOperation replaceWithValueOf(Object value) {
Assert.notNull(value, "Value must not be null!"); Assert.notNull(value, "Value must not be null");
return new ReplaceWithOperation((ctx) -> { return new ReplaceWithOperation((ctx) -> {
Object target = value instanceof String ? Fields.field((String) value) : value; Object target = value instanceof String ? Fields.field((String) value) : value;

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

@ -38,7 +38,7 @@ public class SampleOperation implements AggregationOperation {
*/ */
public SampleOperation(long sampleSize) { public SampleOperation(long sampleSize) {
Assert.isTrue(sampleSize > 0, "Sample size must be greater than zero!"); Assert.isTrue(sampleSize > 0, "Sample size must be greater than zero");
this.sampleSize = sampleSize; this.sampleSize = sampleSize;
} }

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

@ -99,7 +99,7 @@ public class ScriptOperators {
*/ */
public static Function function(String body) { public static Function function(String body) {
Assert.notNull(body, "Function body must not be null!"); Assert.notNull(body, "Function body must not be null");
Map<String, Object> function = new LinkedHashMap<>(2); Map<String, Object> function = new LinkedHashMap<>(2);
function.put(Fields.BODY.toString(), body); function.put(Fields.BODY.toString(), body);
@ -127,7 +127,7 @@ public class ScriptOperators {
*/ */
public Function args(List<Object> args) { public Function args(List<Object> args) {
Assert.notNull(args, "Args must not be null! Use an empty list instead."); Assert.notNull(args, "Args must not be null Use an empty list instead");
return new Function(appendAt(1, Fields.ARGS.toString(), args)); return new Function(appendAt(1, Fields.ARGS.toString(), args));
} }
@ -140,7 +140,7 @@ public class ScriptOperators {
*/ */
public Function lang(String lang) { public Function lang(String lang) {
Assert.hasText(lang, "Lang must not be null nor empty! The default would be 'js'."); Assert.hasText(lang, "Lang must not be null nor empty; The default would be 'js'");
return new Function(appendAt(2, Fields.LANG.toString(), lang)); return new Function(appendAt(2, Fields.LANG.toString(), lang));
} }
@ -528,7 +528,7 @@ public class ScriptOperators {
*/ */
public AccumulatorBuilder lang(String lang) { public AccumulatorBuilder lang(String lang) {
Assert.hasText(lang, "Lang must not be null nor empty! The default would be 'js'."); Assert.hasText(lang, "Lang must not be null nor empty; The default would be 'js'");
this.lang = lang; this.lang = lang;
return this; return this;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save