From 5cf8ec3e550284f2c7753dd42bd6e6673abd211e Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Wed, 14 Dec 2016 09:46:50 +0100 Subject: [PATCH] DATAMONGO-1552 - Polishing. Updated doc, removed whitespaces, minor method wording changes. Original Pull Request: #426 --- .../mongodb/core/aggregation/Aggregation.java | 6 ++ .../AggregationOperationRenderer.java | 2 +- .../core/aggregation/BucketAutoOperation.java | 39 +++++----- .../core/aggregation/BucketOperation.java | 17 ++-- .../aggregation/BucketOperationSupport.java | 78 +++++++------------ .../core/aggregation/FacetOperation.java | 35 ++++----- .../BucketAutoOperationUnitTests.java | 2 +- .../aggregation/BucketOperationUnitTests.java | 2 +- .../aggregation/FacetOperationUnitTests.java | 2 +- 9 files changed, 84 insertions(+), 99 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java index 4fd739d8c..544910373 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java @@ -422,6 +422,7 @@ public class Aggregation { * * @param groupByField must not be {@literal null} or empty. * @return + * @since 1.10 */ public static BucketOperation bucket(String groupByField) { return new BucketOperation(field(groupByField)); @@ -432,6 +433,7 @@ public class Aggregation { * * @param groupByExpression must not be {@literal null}. * @return + * @since 1.10 */ public static BucketOperation bucket(AggregationExpression groupByExpression) { return new BucketOperation(groupByExpression); @@ -443,6 +445,7 @@ public class Aggregation { * @param groupByField must not be {@literal null} or empty. * @param buckets number of buckets, must be a positive integer. * @return + * @since 1.10 */ public static BucketAutoOperation bucketAuto(String groupByField, int buckets) { return new BucketAutoOperation(field(groupByField), buckets); @@ -454,6 +457,7 @@ public class Aggregation { * @param groupByExpression must not be {@literal null}. * @param buckets number of buckets, must be a positive integer. * @return + * @since 1.10 */ public static BucketAutoOperation bucketAuto(AggregationExpression groupByExpression, int buckets) { return new BucketAutoOperation(groupByExpression, buckets); @@ -463,6 +467,7 @@ public class Aggregation { * Creates a new {@link FacetOperation}. * * @return + * @since 1.10 */ public static FacetOperation facet() { return FacetOperation.EMPTY; @@ -473,6 +478,7 @@ public class Aggregation { * * @param aggregationOperations the sub-pipeline, must not be {@literal null}. * @return + * @since 1.10 */ public static FacetOperationBuilder facet(AggregationOperation... aggregationOperations) { return facet().and(aggregationOperations); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOperationRenderer.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOperationRenderer.java index b6094c3a2..0acc0ac4f 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOperationRenderer.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOperationRenderer.java @@ -39,7 +39,7 @@ class AggregationOperationRenderer { /** * Render a {@link List} of {@link AggregationOperation} given {@link AggregationOperationContext} into their * {@link Document} representation. - * + * * @param operations must not be {@literal null}. * @param context must not be {@literal null}. * @return the {@link List} of {@link Document}. diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperation.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperation.java index 24c8ced54..db5407279 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperation.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperation.java @@ -22,18 +22,18 @@ import org.springframework.util.Assert; import org.bson.Document; /** - * Encapsulates the aggregation framework {@code $bucketAuto}-operation. - *

+ * Encapsulates the aggregation framework {@code $bucketAuto}-operation.
* Bucket stage is typically used with {@link Aggregation} and {@code $facet}. Categorizes incoming documents into a * specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically - * determined in an attempt to evenly distribute the documents into the specified number of buckets. - *

- * We recommend to use the static factory method {@link Aggregation#bucketAuto(String, int)} instead of creating instances of - * this class directly. + * determined in an attempt to evenly distribute the documents into the specified number of buckets.
+ * We recommend to use the static factory method {@link Aggregation#bucketAuto(String, int)} instead of creating + * instances of this class directly. * - * @see http://docs.mongodb.org/manual/reference/aggregation/bucketAuto/ + * @see http://docs.mongodb.org/manual/reference/aggregation/bucketAuto/ * @see BucketOperationSupport * @author Mark Paluch + * @author Christoph Strobl * @since 1.10 */ public class BucketAutoOperation extends BucketOperationSupport @@ -122,8 +122,10 @@ public class BucketAutoOperation extends BucketOperationSupport + * Use either predefined {@link Granularities} or provide a own one. * * @param granularity must not be {@literal null}. * @return @@ -132,7 +134,7 @@ public class BucketAutoOperation extends BucketOperationSupporthttp://docs.mongodb.org/manual/reference/aggregation/bucket/ * @see BucketOperationSupport * @author Mark Paluch * @since 1.10 @@ -108,7 +108,7 @@ public class BucketOperation extends BucketOperationSupport newBoundaries = new ArrayList(this.boundaries.size() + boundaries.length); newBoundaries.addAll(this.boundaries); @@ -196,7 +197,7 @@ public class BucketOperation extends BucketOperationSupport - * Bucket stages collect documents into buckets and can contribute output fields. - *

+ * Base class for bucket operations that support output expressions the aggregation framework.
+ * Bucket stages collect documents into buckets and can contribute output fields.
* Implementing classes are required to provide an {@link OutputBuilder}. * - * @see http://docs.mongodb.org/manual/reference/aggregation/bucket/ * @author Mark Paluch + * @author Christoph Strobl * @since 1.10 */ public abstract class BucketOperationSupport, B extends OutputBuilder> @@ -49,7 +47,7 @@ public abstract class BucketOperationSupport operationSupport) { @@ -87,7 +84,7 @@ public abstract class BucketOperationSupport, T extends BucketOperationSupport> @@ -231,11 +228,9 @@ public abstract class BucketOperationSupport + * Generates a builder for a {@code $sum}-expression.
* Count expressions are emulated via {@code $sum: 1}. - *

- * + * * @return */ public B count() { @@ -244,7 +239,7 @@ public abstract class BucketOperationSupport + * Encapsulates an output field in a bucket aggregation stage.
* Output fields can be either top-level fields that define a valid field name or nested output fields using * operators. - * + * * @author Mark Paluch */ protected abstract static class Output implements AggregationExpression { @@ -513,17 +503,10 @@ public abstract class BucketOperationSupport + * Output field that uses a Mongo operation (expression object) to generate an output field value.
* {@link OperationOutput} is used either with a regular field name or an operation keyword (e.g. * {@literal $sum, $count}). * @@ -623,7 +606,6 @@ public abstract class BucketOperationSupport + * Encapsulates the aggregation framework {@code $facet}-operation.
* Facet of {@link AggregationOperation}s to be used in an {@link Aggregation}. Processes multiple * {@link AggregationOperation} pipelines within a single stage on the same set of input documents. Each sub-pipeline * has its own field in the output document where its results are stored as an array of documents. * {@link FacetOperation} enables various aggregations on the same set of input documents, without needing to retrieve - * the input documents multiple times. - *

+ * the input documents multiple times.
* As of MongoDB 3.4, {@link FacetOperation} cannot be used with nested pipelines containing {@link GeoNearOperation}, - * {@link OutOperation} and {@link FacetOperation}. - *

+ * {@link OutOperation} and {@link FacetOperation}.
* We recommend to use the static factory method {@link Aggregation#facet()} instead of creating instances of this class * directly. * * @see http://docs.mongodb.org/manual/reference/aggregation/facet/ * @author Mark Paluch + * @author Christoph Strobl * @since 1.10 */ public class FacetOperation implements FieldsExposingAggregationOperation { @@ -66,11 +64,10 @@ public class FacetOperation implements FieldsExposingAggregationOperation { } /** - * Creates a new {@link FacetOperationBuilder} to append a new facet using {@literal operations}. - *

+ * Creates a new {@link FacetOperationBuilder} to append a new facet using {@literal operations}.
* {@link FacetOperationBuilder} takes a pipeline of {@link AggregationOperation} to categorize documents into a * single facet. - * + * * @param operations must not be {@literal null} or empty. * @return */ @@ -117,7 +114,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * Creates a new {@link FacetOperation} that contains the configured pipeline of {@link AggregationOperation} * exposed as {@literal fieldName} in the resulting facet document. - * + * * @param fieldName must not be {@literal null} or empty. * @return */ @@ -131,7 +128,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * Encapsulates multiple {@link Facet}s - * + * * @author Mark Paluch */ private static class Facets { @@ -142,7 +139,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * Creates a new {@link Facets} given {@link List} of {@link Facet}. - * + * * @param facets */ private Facets(List facets) { @@ -152,7 +149,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * @return the {@link ExposedFields} derived from {@link Output}. */ - protected ExposedFields asExposedFields() { + ExposedFields asExposedFields() { ExposedFields fields = ExposedFields.from(); @@ -176,12 +173,12 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * Adds a facet to this {@link Facets}. - * + * * @param fieldName must not be {@literal null}. * @param operations must not be {@literal null}. * @return the new {@link Facets}. */ - public Facets and(String fieldName, List operations) { + Facets and(String fieldName, List operations) { Assert.hasText(fieldName, "FieldName must not be null or empty!"); Assert.notNull(operations, "AggregationOperations must not be null!"); @@ -196,7 +193,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * A single facet with a {@link ExposedField} and its {@link AggregationOperation} pipeline. - * + * * @author Mark Paluch */ private static class Facet { @@ -206,11 +203,11 @@ public class FacetOperation implements FieldsExposingAggregationOperation { /** * Creates a new {@link Facet} given {@link ExposedField} and {@link AggregationOperation} pipeline. - * + * * @param exposedField must not be {@literal null}. * @param operations must not be {@literal null}. */ - protected Facet(ExposedField exposedField, List operations) { + Facet(ExposedField exposedField, List operations) { Assert.notNull(exposedField, "ExposedField must not be null!"); Assert.notNull(operations, "AggregationOperations must not be null!"); @@ -219,7 +216,7 @@ public class FacetOperation implements FieldsExposingAggregationOperation { this.operations = operations; } - protected ExposedField getExposedField() { + ExposedField getExposedField() { return exposedField; } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperationUnitTests.java index 41e303e5c..beb88e7e4 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketAutoOperationUnitTests.java @@ -27,7 +27,7 @@ import org.bson.Document; /** * Unit tests for {@link BucketAutoOperation}. - * + * * @author Mark Paluch */ public class BucketAutoOperationUnitTests { diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketOperationUnitTests.java index ac2b442a1..ac3a0ccd4 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/BucketOperationUnitTests.java @@ -27,7 +27,7 @@ import org.bson.Document; /** * Unit tests for {@link BucketOperation}. - * + * * @author Mark Paluch */ public class BucketOperationUnitTests { diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/FacetOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/FacetOperationUnitTests.java index f85380d39..55c4a8fc5 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/FacetOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/FacetOperationUnitTests.java @@ -26,7 +26,7 @@ import org.bson.Document; /** * Unit tests for {@link FacetOperation}. - * + * * @author Mark Paluch * @soundtrack Stanley Foort - You Make Me Believe In Magic (Extended Mix) */