Skip to content

Commit cf1d0b8

Browse files
committed
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.
1 parent da9a249 commit cf1d0b8

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.NearQuery;
3333
import org.springframework.data.mongodb.core.query.SerializationUtils;
@@ -384,68 +384,6 @@ public static LookupOperation lookup(Field from, Field localField, Field foreign
384384
return new LookupOperation(from, localField, foreignField, as);
385385
}
386386

387-
/**
388-
* Creates a new {@link IfNullOperator} for the given {@code field} and {@code replacement} value.
389-
*
390-
* @param field must not be {@literal null}.
391-
* @param replacement must not be {@literal null}.
392-
* @return never {@literal null}.
393-
* @since 1.10
394-
*/
395-
public static IfNullOperator ifNull(String field, Object replacement) {
396-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
397-
}
398-
399-
/**
400-
* Creates a new {@link IfNullOperator} for the given {@link Field} and {@link Field} to obtain a value from.
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(Field field, Field replacement) {
408-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
409-
}
410-
411-
/**
412-
* Creates a new {@link IfNullOperator} for the given {@link Field} and {@code replacement} value.
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, Object replacement) {
420-
return IfNullOperator.newBuilder().ifNull(field).thenReplaceWith(replacement);
421-
}
422-
423-
/**
424-
* Creates a new {@link ConditionalOperator} for the given {@link Field} that holds a {@literal boolean} value.
425-
*
426-
* @param booleanField must not be {@literal null}.
427-
* @param then must not be {@literal null}.
428-
* @param otherwise must not be {@literal null}.
429-
* @return never {@literal null}.
430-
* @since 1.10
431-
*/
432-
public static ConditionalOperator conditional(Field booleanField, Object then, Object otherwise) {
433-
return ConditionalOperator.newBuilder().when(booleanField).then(then).otherwise(otherwise);
434-
}
435-
436-
/**
437-
* Creates a new {@link ConditionalOperator} for the given {@link Criteria}.
438-
*
439-
* @param criteria must not be {@literal null}.
440-
* @param then must not be {@literal null}.
441-
* @param otherwise must not be {@literal null}.
442-
* @return never {@literal null}.
443-
* @since 1.10
444-
*/
445-
public static ConditionalOperator conditional(Criteria criteria, Object then, Object otherwise) {
446-
return ConditionalOperator.newBuilder().when(criteria).then(then).otherwise(otherwise);
447-
}
448-
449387
/**
450388
* Creates a new {@link Fields} instance for the given field names.
451389
*

0 commit comments

Comments
 (0)