Skip to content

Commit b98bc0e

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 f64d205 commit b98bc0e

File tree

11 files changed

+924
-834
lines changed

11 files changed

+924
-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
@@ -24,11 +24,11 @@
2424
import org.bson.Document;
2525
import org.springframework.data.domain.Sort;
2626
import org.springframework.data.domain.Sort.Direction;
27+
import org.springframework.data.mongodb.core.aggregation.ExposedFields.DirectFieldReference;
2728
import org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField;
2829
import org.springframework.data.mongodb.core.aggregation.ExposedFields.FieldReference;
29-
import org.springframework.data.mongodb.core.aggregation.ExposedFields.DirectFieldReference;
30-
import org.springframework.data.mongodb.core.aggregation.Fields.AggregationField;
3130
import org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation;
31+
import org.springframework.data.mongodb.core.aggregation.Fields.*;
3232
import org.springframework.data.mongodb.core.query.Criteria;
3333
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
3434
import org.springframework.data.mongodb.core.query.NearQuery;
@@ -394,68 +394,6 @@ public static LookupOperation lookup(Field from, Field localField, Field foreign
394394
return new LookupOperation(from, localField, foreignField, as);
395395
}
396396

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

0 commit comments

Comments
 (0)