Skip to content

Commit fd0a402

Browse files
committed
Polishing.
See #3720 Original pull request: #3745.
1 parent 6bd0f75 commit fd0a402

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

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

+19-18
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private boolean usesCriteriaDefinition() {
236236
*
237237
* @author Mark Paluch
238238
* @see <a href=
239-
* "https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/">https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/</a>
239+
* "https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/">https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/</a>
240240
*/
241241
public static class IfNull implements AggregationExpression {
242242

@@ -252,7 +252,8 @@ private IfNull(Object condition, Object value) {
252252
/**
253253
* Creates new {@link IfNull}.
254254
*
255-
* @param fieldReference the field to check for a {@literal null} value, field reference must not be {@literal null}.
255+
* @param fieldReference the field to check for a {@literal null} value, field reference must not be
256+
* {@literal null}.
256257
* @return never {@literal null}.
257258
*/
258259
public static ThenBuilder ifNull(String fieldReference) {
@@ -265,7 +266,7 @@ public static ThenBuilder ifNull(String fieldReference) {
265266
* Creates new {@link IfNull}.
266267
*
267268
* @param expression the expression to check for a {@literal null} value, field reference must not be
268-
* {@literal null}.
269+
* {@literal null}.
269270
* @return never {@literal null}.
270271
*/
271272
public static ThenBuilder ifNull(AggregationExpression expression) {
@@ -283,8 +284,8 @@ public Document toDocument(AggregationOperationContext context) {
283284

284285
List<Object> list = new ArrayList<Object>();
285286

286-
if(condition instanceof Collection) {
287-
for(Object val : ((Collection)this.condition)) {
287+
if (condition instanceof Collection) {
288+
for (Object val : ((Collection) this.condition)) {
288289
list.add(mapCondition(val, context));
289290
}
290291
} else {
@@ -326,14 +327,14 @@ public interface IfNullBuilder {
326327

327328
/**
328329
* @param fieldReference the field to check for a {@literal null} value, field reference must not be
329-
* {@literal null}.
330+
* {@literal null}.
330331
* @return the {@link ThenBuilder}
331332
*/
332333
ThenBuilder ifNull(String fieldReference);
333334

334335
/**
335336
* @param expression the expression to check for a {@literal null} value, field name must not be {@literal null}
336-
* or empty.
337+
* or empty.
337338
* @return the {@link ThenBuilder}.
338339
*/
339340
ThenBuilder ifNull(AggregationExpression expression);
@@ -346,7 +347,8 @@ public interface IfNullBuilder {
346347
public interface OrBuilder {
347348

348349
/**
349-
* @param fieldReference the field to check for a {@literal null} value, field reference must not be {@literal null}.
350+
* @param fieldReference the field to check for a {@literal null} value, field reference must not be
351+
* {@literal null}.
350352
* @return the {@link ThenBuilder}
351353
*/
352354
ThenBuilder orIfNull(String fieldReference);
@@ -365,8 +367,8 @@ public interface ThenBuilder extends OrBuilder {
365367

366368
/**
367369
* @param value the value to be used if the {@code $ifNull} condition evaluates {@literal true}. Can be a
368-
* {@link Document}, a value that is supported by MongoDB or a value that can be converted to a MongoDB
369-
* representation but must not be {@literal null}.
370+
* {@link Document}, a value that is supported by MongoDB or a value that can be converted to a MongoDB
371+
* representation but must not be {@literal null}.
370372
* @return new instance of {@link IfNull}.
371373
*/
372374
IfNull then(Object value);
@@ -499,7 +501,7 @@ public static Switch switchCases(CaseOperator... conditions) {
499501
public static Switch switchCases(List<CaseOperator> conditions) {
500502

501503
Assert.notNull(conditions, "Conditions must not be null!");
502-
return new Switch(Collections.<String, Object>singletonMap("branches", new ArrayList<CaseOperator>(conditions)));
504+
return new Switch(Collections.<String, Object> singletonMap("branches", new ArrayList<CaseOperator>(conditions)));
503505
}
504506

505507
/**
@@ -586,7 +588,7 @@ public interface ThenBuilder {
586588
* @author Mark Paluch
587589
* @author Christoph Strobl
588590
* @see <a href=
589-
* "https://docs.mongodb.com/manual/reference/operator/aggregation/cond/">https://docs.mongodb.com/manual/reference/operator/aggregation/cond/</a>
591+
* "https://docs.mongodb.com/manual/reference/operator/aggregation/cond/">https://docs.mongodb.com/manual/reference/operator/aggregation/cond/</a>
590592
*/
591593
public static class Cond implements AggregationExpression {
592594

@@ -847,8 +849,8 @@ public interface ThenBuilder {
847849

848850
/**
849851
* @param value the value to be used if the condition evaluates {@literal true}. Can be a {@link Document}, a
850-
* value that is supported by MongoDB or a value that can be converted to a MongoDB representation but
851-
* must not be {@literal null}.
852+
* value that is supported by MongoDB or a value that can be converted to a MongoDB representation but
853+
* must not be {@literal null}.
852854
* @return the {@link OtherwiseBuilder}
853855
*/
854856
OtherwiseBuilder then(Object value);
@@ -873,8 +875,8 @@ public interface OtherwiseBuilder {
873875

874876
/**
875877
* @param value the value to be used if the condition evaluates {@literal false}. Can be a {@link Document}, a
876-
* value that is supported by MongoDB or a value that can be converted to a MongoDB representation but
877-
* must not be {@literal null}.
878+
* value that is supported by MongoDB or a value that can be converted to a MongoDB representation but
879+
* must not be {@literal null}.
878880
* @return the {@link Cond}
879881
*/
880882
Cond otherwise(Object value);
@@ -902,8 +904,7 @@ static class ConditionalExpressionBuilder implements WhenBuilder, ThenBuilder, O
902904
private @Nullable Object condition;
903905
private @Nullable Object thenValue;
904906

905-
private ConditionalExpressionBuilder() {
906-
}
907+
private ConditionalExpressionBuilder() {}
907908

908909
/**
909910
* Creates a new builder for {@link Cond}.

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperatorsUnitTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import org.junit.jupiter.api.Test;
2323

2424
/**
25+
* Unit tests for {@link ConditionalOperators}.
26+
*
2527
* @author Christoph Strobl
2628
*/
27-
public class ConditionalOperatorsUnitTests {
29+
class ConditionalOperatorsUnitTests {
2830

2931
@Test // GH-3720
3032
void rendersIfNullWithMultipleConditionalValuesCorrectly() {

0 commit comments

Comments
 (0)