Browse Source

DATAMONGO-1843 - Polishing.

Convert anonymous classes to lambdas. Typo fixes. Migrate test to AssertJ.

Original pull request: #526.
pull/528/merge
Mark Paluch 8 years ago
parent
commit
047eb18600
  1. 20
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArrayOperators.java
  2. 522
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperationUnitTests.java

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

@ -32,6 +32,7 @@ import org.springframework.util.Assert;
* Gateway to {@literal array} aggregation operations. * Gateway to {@literal array} aggregation operations.
* *
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
* @since 1.0 * @since 1.0
*/ */
public class ArrayOperators { public class ArrayOperators {
@ -224,16 +225,11 @@ public class ArrayOperators {
* @param expression must not be {@literal null}. * @param expression must not be {@literal null}.
* @return * @return
*/ */
public ArrayOperatorFactory.ReduceInitialValueBuilder reduce(final AggregationExpression expression) { public ArrayOperatorFactory.ReduceInitialValueBuilder reduce(AggregationExpression expression) {
return new ArrayOperatorFactory.ReduceInitialValueBuilder() {
@Override return initialValue -> (usesFieldRef() ? Reduce.arrayOf(fieldReference)
public Reduce startingWith(Object initialValue) {
return (usesFieldRef() ? Reduce.arrayOf(fieldReference)
: Reduce.arrayOf(ArrayOperatorFactory.this.expression)).withInitialValue(initialValue).reduce(expression); : Reduce.arrayOf(ArrayOperatorFactory.this.expression)).withInitialValue(initialValue).reduce(expression);
} }
};
}
/** /**
* Start creating new {@link AggregationExpression} that applies an {@link AggregationExpression} to each element in * Start creating new {@link AggregationExpression} that applies an {@link AggregationExpression} to each element in
@ -242,17 +238,11 @@ public class ArrayOperators {
* @param expressions * @param expressions
* @return * @return
*/ */
public ArrayOperatorFactory.ReduceInitialValueBuilder reduce(final PropertyExpression... expressions) { public ArrayOperatorFactory.ReduceInitialValueBuilder reduce(PropertyExpression... expressions) {
return new ArrayOperatorFactory.ReduceInitialValueBuilder() {
@Override return initialValue -> (usesFieldRef() ? Reduce.arrayOf(fieldReference) : Reduce.arrayOf(expression))
public Reduce startingWith(Object initialValue) {
return (usesFieldRef() ? Reduce.arrayOf(fieldReference) : Reduce.arrayOf(expression))
.withInitialValue(initialValue).reduce(expressions); .withInitialValue(initialValue).reduce(expressions);
} }
};
}
/** /**
* Creates new {@link AggregationExpression} that transposes an array of input arrays so that the first element of * Creates new {@link AggregationExpression} that transposes an array of input arrays so that the first element of

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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save