Skip to content

Commit 1a11877

Browse files
mp911dechristophstrobl
authored andcommitted
DATAMONGO-1542 - Refactor CondOperator and IfNullOperator to children of AggregationExpressions.
Renamed CondOperator to Cond and IfNullOperator to IfNull. Both conditional operations are now available from ConditionalOperators.when and ConditionalOperators.ifNull and accept AggregationExpressions for conditions and values. Original Pull Request: #421
1 parent ea4782c commit 1a11877

File tree

11 files changed

+921
-834
lines changed

11 files changed

+921
-834
lines changed

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

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
import org.springframework.data.domain.Sort;
2525
import org.springframework.data.domain.Sort.Direction;
26+
import org.springframework.data.mongodb.core.aggregation.ExposedFields.DirectFieldReference;
2627
import org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField;
2728
import org.springframework.data.mongodb.core.aggregation.ExposedFields.FieldReference;
28-
import org.springframework.data.mongodb.core.aggregation.ExposedFields.DirectFieldReference;
29-
import org.springframework.data.mongodb.core.aggregation.Fields.AggregationField;
3029
import org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation;
30+
import org.springframework.data.mongodb.core.aggregation.Fields.*;
3131
import org.springframework.data.mongodb.core.query.Criteria;
3232
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
3333
import org.springframework.data.mongodb.core.query.NearQuery;
@@ -396,68 +396,6 @@ public static LookupOperation lookup(Field from, Field localField, Field foreign
396396
return new LookupOperation(from, localField, foreignField, as);
397397
}
398398

399-
/**
400-
* Creates a new {@link IfNullOperator} for the given {@code field} and {@code replacement} value.
401-
*
402-
* @param field must not be {@literal null}.
403-
* @param replacement must not be {@literal null}.
404-
* @return never {@literal null}.
405-
* @since 1.10
406-
*/
407-
public static IfNullOperator ifNull(String field, Object replacement) {
408-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
409-
}
410-
411-
/**
412-
* Creates a new {@link IfNullOperator} for the given {@link Field} and {@link Field} to obtain a value from.
413-
*
414-
* @param field must not be {@literal null}.
415-
* @param replacement must not be {@literal null}.
416-
* @return never {@literal null}.
417-
* @since 1.10
418-
*/
419-
public static IfNullOperator ifNull(Field field, Field replacement) {
420-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
421-
}
422-
423-
/**
424-
* Creates a new {@link IfNullOperator} for the given {@link Field} and {@code replacement} value.
425-
*
426-
* @param field must not be {@literal null}.
427-
* @param replacement must not be {@literal null}.
428-
* @return never {@literal null}.
429-
* @since 1.10
430-
*/
431-
public static IfNullOperator ifNull(Field field, Object replacement) {
432-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
433-
}
434-
435-
/**
436-
* Creates a new {@link ConditionalOperator} for the given {@link Field} that holds a {@literal boolean} value.
437-
*
438-
* @param booleanField must not be {@literal null}.
439-
* @param then must not be {@literal null}.
440-
* @param otherwise must not be {@literal null}.
441-
* @return never {@literal null}.
442-
* @since 1.10
443-
*/
444-
public static ConditionalOperator conditional(Field booleanField, Object then, Object otherwise) {
445-
return ConditionalOperator.newBuilder().when(booleanField).then(then).otherwise(otherwise);
446-
}
447-
448-
/**
449-
* Creates a new {@link ConditionalOperator} for the given {@link Criteria}.
450-
*
451-
* @param criteria must not be {@literal null}.
452-
* @param then must not be {@literal null}.
453-
* @param otherwise must not be {@literal null}.
454-
* @return never {@literal null}.
455-
* @since 1.10
456-
*/
457-
public static ConditionalOperator conditional(Criteria criteria, Object then, Object otherwise) {
458-
return ConditionalOperator.newBuilder().when(criteria).then(then).otherwise(otherwise);
459-
}
460-
461399
/**
462400
* Creates a new {@link Fields} instance for the given field names.
463401
*

0 commit comments

Comments
 (0)