Skip to content

Commit f512d8c

Browse files
DATAMONGO-1542 - Polishing.
Added some static entry points for better readability. Original Pull Request: #421
1 parent b98bc0e commit f512d8c

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6436,12 +6436,52 @@ private void assertNotBuilder(Object toCheck, String name) {
64366436
/**
64376437
* Get a builder that allows fluent creation of {@link Cond}.
64386438
*
6439-
* @return a new {@link ConditionalExpressionBuilder}.
6439+
* @return never {@literal null}.
64406440
*/
6441-
public static ConditionalExpressionBuilder newBuilder() {
6441+
public static WhenBuilder newBuilder() {
64426442
return ConditionalExpressionBuilder.newBuilder();
64436443
}
64446444

6445+
/**
6446+
* Start creating new {@link Cond} by providing the boolean expression used in {@code if}.
6447+
*
6448+
* @param booleanExpression must not be {@literal null}.
6449+
* @return never {@literal null}.
6450+
*/
6451+
public static ThenBuilder when(Document booleanExpression) {
6452+
return ConditionalExpressionBuilder.newBuilder().when(booleanExpression);
6453+
}
6454+
6455+
/**
6456+
* Start creating new {@link Cond} by providing the {@link AggregationExpression} used in {@code if}.
6457+
*
6458+
* @param expression expression that yields in a boolean result, must not be {@literal null}.
6459+
* @return never {@literal null}.
6460+
*/
6461+
public static ThenBuilder when(AggregationExpression expression) {
6462+
return ConditionalExpressionBuilder.newBuilder().when(expression);
6463+
}
6464+
6465+
/**
6466+
* Start creating new {@link Cond} by providing the field reference used in {@code if}.
6467+
*
6468+
* @param booleanField name of a field holding a boolean value, must not be {@literal null}.
6469+
* @return never {@literal null}.
6470+
*/
6471+
public static ThenBuilder when(String booleanField) {
6472+
return ConditionalExpressionBuilder.newBuilder().when(booleanField);
6473+
}
6474+
6475+
/**
6476+
* Start creating new {@link Cond} by providing the {@link CriteriaDefinition} used in {@code if}.
6477+
*
6478+
* @param criteria criteria to evaluate, must not be {@literal null}.
6479+
* @return the {@link ThenBuilder}
6480+
*/
6481+
public static ThenBuilder when(CriteriaDefinition criteria) {
6482+
return ConditionalExpressionBuilder.newBuilder().when(criteria);
6483+
}
6484+
64456485
/**
64466486
* @author Mark Paluch
64476487
*/

0 commit comments

Comments
 (0)