Skip to content

Commit 1408d51

Browse files
committed
DATAMONGO-979 - Polishing.
Minor JavaDoc and code style polishes. Original pull request: spring-projects#272.
1 parent f5c319f commit 1408d51

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818
import com.mongodb.DBObject;
1919

2020
/**
21-
* An {@link AggregationExpression} can be used with field expressions in aggregation pipeline stages like {@code project} and
22-
* {@code group}.
21+
* An {@link AggregationExpression} can be used with field expressions in aggregation pipeline stages like
22+
* {@code project} and {@code group}.
2323
*
2424
* @author Thomas Darimont
25+
* @author Oliver Gierke
2526
*/
26-
public interface AggregationExpression {
27+
interface AggregationExpression {
2728

2829
/**
30+
* Turns the {@link AggregationExpression} into a {@link DBObject} within the given
31+
* {@link AggregationOperationContext}.
32+
*
2933
* @param context
3034
* @return
3135
*/

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,43 @@
2727
* An enum of supported {@link AggregationExpression}s in aggregation pipeline stages.
2828
*
2929
* @author Thomas Darimont
30+
* @author Oliver Gierke
3031
* @since 1.10
3132
*/
3233
public enum AggregationFunctionExpressions {
3334

3435
SIZE;
3536

3637
/**
37-
* Returns an {@link AggregationExpression} build from the current {@link Enum} name and the given {@code params}.
38+
* Returns an {@link AggregationExpression} build from the current {@link Enum} name and the given parameters.
3839
*
39-
* @param params must not be {@literal null}
40+
* @param parameters must not be {@literal null}
4041
* @return
4142
*/
42-
public AggregationExpression of(Object... params) {
43+
public AggregationExpression of(Object... parameters) {
4344

44-
Assert.notNull(params, "Params must not be null!");
45-
46-
return new FunctionExpression(name().toLowerCase(), params);
45+
Assert.notNull(parameters, "Parameters must not be null!");
46+
return new FunctionExpression(name().toLowerCase(), parameters);
4747
}
4848

4949
/**
5050
* An {@link AggregationExpression} representing a function call.
5151
*
5252
* @author Thomas Darimont
53+
* @author Oliver Gierke
5354
* @since 1.10
5455
*/
5556
static class FunctionExpression implements AggregationExpression {
5657

5758
private final String name;
5859
private final Object[] values;
5960

61+
/**
62+
* Creates a new {@link FunctionExpression} for the given name and values.
63+
*
64+
* @param name must not be {@literal null} or empty.
65+
* @param values must not be {@literal null}.
66+
*/
6067
public FunctionExpression(String name, Object[] values) {
6168

6269
Assert.hasText(name, "Name must not be null!");
@@ -66,21 +73,23 @@ public FunctionExpression(String name, Object[] values) {
6673
this.values = values;
6774
}
6875

69-
/* (non-Javadoc)
76+
/*
77+
* (non-Javadoc)
7078
* @see org.springframework.data.mongodb.core.aggregation.Expression#toDbObject(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext)
7179
*/
7280
@Override
7381
public DBObject toDbObject(AggregationOperationContext context) {
7482

7583
List<Object> args = new ArrayList<Object>(values.length);
84+
7685
for (int i = 0; i < values.length; i++) {
7786
args.add(unpack(values[i], context));
7887
}
7988

8089
return new BasicDBObject("$" + name, args);
8190
}
8291

83-
private Object unpack(Object value, AggregationOperationContext context) {
92+
private static Object unpack(Object value, AggregationOperationContext context) {
8493

8594
if (value instanceof AggregationExpression) {
8695
return ((AggregationExpression) value).toDbObject(context);

0 commit comments

Comments
 (0)