From 8af904b81fb190e6b9663629daff76b11ed8028f Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 6 Sep 2021 15:46:07 +0200 Subject: [PATCH] Polishing. Add author and since tags. Tweak Javadoc format. See #3709 Original pull request: #3794. --- .../core/aggregation/ArithmeticOperators.java | 155 +++++++++--------- .../ArithmeticOperatorsUnitTests.java | 46 +++--- .../reference/aggregation-framework.adoc | 2 +- 3 files changed, 93 insertions(+), 110 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java index bf10488f9..d21d98588 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java @@ -717,7 +717,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the sine of a numeric value given in * {@link AngularUnit#RADIANS radians}. * - * @return new instance of {@link Sin}. + * @return new instance of {@link Sinh}. * @since 3.3 */ public Sinh sinh() { @@ -728,7 +728,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the sine of a numeric value. * * @param unit the unit of measure. - * @return new instance of {@link Sin}. + * @return new instance of {@link Sinh}. * @since 3.3 */ public Sinh sinh(AngularUnit unit) { @@ -739,7 +739,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the cosine of a numeric value given in * {@link AngularUnit#RADIANS radians}. * - * @return new instance of {@link Sin}. + * @return new instance of {@link Cos}. * @since 3.3 */ public Cos cos() { @@ -751,7 +751,7 @@ public class ArithmeticOperators { * {@link AngularUnit unit}. * * @param unit the unit of measure. - * @return new instance of {@link Sin}. + * @return new instance of {@link Cos}. * @since 3.3 */ public Cos cos(AngularUnit unit) { @@ -762,7 +762,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value given in * {@link AngularUnit#RADIANS radians}. * - * @return new instance of {@link Sin}. + * @return new instance of {@link Cosh}. * @since 3.3 */ public Cosh cosh() { @@ -773,7 +773,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value. * * @param unit the unit of measure. - * @return new instance of {@link Sin}. + * @return new instance of {@link Cosh}. * @since 3.3 */ public Cosh cosh(AngularUnit unit) { @@ -784,70 +784,75 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the tangent of a numeric value given in * {@link AngularUnit#RADIANS radians}. * - * @return new instance of {@link Sin}. + * @return new instance of {@link Tan}. * @since 3.3 */ public Tan tan() { return tan(AngularUnit.RADIANS); } - + /** * Creates new {@link AggregationExpression} that calculates the inverse tangent of a numeric value. * * @return new instance of {@link ATan}. + * @since 3.3 */ public ATan atan() { return usesFieldRef() ? ATan.atanOf(fieldReference) : ATan.atanOf(expression); } - + /** - * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value - * divided by the given numeric value in the argument. + * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value divided by + * the given numeric value in the argument. * - * @param the numeric value + * @param the numeric value * @return new instance of {@link ATan2}. + * @since 3.3 */ public ATan2 atan2(Number value) { - + Assert.notNull(value, "Value must not be null!"); return createATan2().atan2of(value); } - + /** - * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value - * divided by the given field reference in the argument. + * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value divided by + * the given field reference in the argument. * - * @param the numeric value + * @param the numeric value * @return new instance of {@link ATan2}. + * @since 3.3 */ public ATan2 atan2(String fieldReference) { - + Assert.notNull(fieldReference, "FieldReference must not be null!"); return createATan2().atan2of(fieldReference); } - + /** - * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value - * divided by the given {@link AggregationExpression} in the argument. + * Creates new {@link AggregationExpression} that calculates the inverse tangent of the the numeric value divided by + * the given {@link AggregationExpression} in the argument. * - * @param the numeric value + * @param the numeric value * @return new instance of {@link ATan2}. + * @since 3.3 */ public ATan2 atan2(AggregationExpression expression) { - + Assert.notNull(expression, "Expression must not be null!"); return createATan2().atan2of(expression); } - + private ATan2 createATan2() { - + return usesFieldRef() ? ATan2.valueOf(fieldReference) : ATan2.valueOf(expression); } - + /** * Creates new {@link AggregationExpression} that calculates the inverse hyperbolic tangent of a numeric value. * * @return new instance of {@link ATanh}. + * @since 3.3 */ public ATanh atanh() { return usesFieldRef() ? ATanh.atanhOf(fieldReference) : ATanh.atanhOf(expression); @@ -858,7 +863,7 @@ public class ArithmeticOperators { * {@link AngularUnit unit}. * * @param unit the unit of measure. - * @return new instance of {@link Sin}. + * @return new instance of {@link Tan}. * @since 3.3 */ public Tan tan(AngularUnit unit) { @@ -869,7 +874,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the hyperbolic tangent of a numeric value given in * {@link AngularUnit#RADIANS radians}. * - * @return new instance of {@link Sin}. + * @return new instance of {@link Tan}. * @since 3.3 */ public Tanh tanh() { @@ -880,7 +885,7 @@ public class ArithmeticOperators { * Creates new {@link AggregationExpression} that calculates the hyperbolic tangent of a numeric value. * * @param unit the unit of measure. - * @return new instance of {@link Sin}. + * @return new instance of {@link Tanh}. * @since 3.3 */ public Tanh tanh(AngularUnit unit) { @@ -2357,8 +2362,6 @@ public class ArithmeticOperators { * { $cos : { $degreesToRadians : "$angle" } } * * - * . - * * @param fieldReference the name of the {@link Field field} that resolves to a numeric value. * @return new instance of {@link Cos}. */ @@ -2470,8 +2473,6 @@ public class ArithmeticOperators { * { $cosh : { $degreesToRadians : "$angle" } } * * - * . - * * @param fieldReference the name of the {@link Field field} that resolves to a numeric value. * @param unit the unit of measure used by the value of the given field. * @return new instance of {@link Cosh}. @@ -2563,8 +2564,6 @@ public class ArithmeticOperators { * { $tan : { $degreesToRadians : "$angle" } } * * - * . - * * @param fieldReference the name of the {@link Field field} that resolves to a numeric value. * @return new instance of {@link Tan}. */ @@ -2641,11 +2640,12 @@ public class ArithmeticOperators { return "$tan"; } } - - + /** * An {@link AggregationExpression expression} that calculates the inverse tangent of a value. * + * @author Divya Srivastava + * @since 3.3 */ public static class ATan extends AbstractAggregationExpression { @@ -2660,14 +2660,13 @@ public class ArithmeticOperators { * @return new instance of {@link ATan}. */ public static ATan atanOf(String fieldReference) { - + Assert.notNull(fieldReference, "FieldReference must not be null!"); return new ATan(Fields.field(fieldReference)); } /** * Creates a new {@link AggregationExpression} that calculates the inverse tangent of a value. - *

* * @param expression the {@link AggregationExpression expression} that resolves to a numeric value. * @return new instance of {@link ATan}. @@ -2683,7 +2682,7 @@ public class ArithmeticOperators { * numeric value. * @return new instance of {@link ATan}. */ - public static ATan atanof(Number value) { + public static ATan atanOf(Number value) { return new ATan(value); } @@ -2692,26 +2691,25 @@ public class ArithmeticOperators { return "$atan"; } } - + /** - * An {@link AggregationExpression expression} that calculates the inverse - * tangent of y / x, where y and x are the first and second values passed to the - * expression respectively. + * An {@link AggregationExpression expression} that calculates the inverse tangent of y / x, where y and x are the + * first and second values passed to the expression respectively. * + * @author Divya Srivastava + * @since 3.3 */ public static class ATan2 extends AbstractAggregationExpression { - + private ATan2(List value) { super(value); } /** - * Creates a new {@link AggregationExpression} that calculates the inverse - * tangent of of y / x, where y and x are the first and second values passed to - * the expression respectively. - * - * @param fieldReference the name of the {@link Field field} that resolves to a - * numeric value. + * Creates a new {@link AggregationExpression} that calculates the inverse tangent of of y / x, where y and x are + * the first and second values passed to the expression respectively. + * + * @param fieldReference the name of the {@link Field field} that resolves to a numeric value. * @return new instance of {@link ATan2}. */ public static ATan2 valueOf(String fieldReference) { @@ -2721,12 +2719,10 @@ public class ArithmeticOperators { } /** - * Creates a new {@link AggregationExpression} that calculates the inverse - * tangent of of y / x, where y and x are the first and second values passed to - * the expression respectively. - * - * @param expression the {@link AggregationExpression expression} that resolves - * to a numeric value. + * Creates a new {@link AggregationExpression} that calculates the inverse tangent of of y / x, where y and x are + * the first and second values passed to the expression respectively. + * + * @param expression the {@link AggregationExpression expression} that resolves to a numeric value. * @return new instance of {@link ATan2}. */ public static ATan2 valueOf(AggregationExpression expression) { @@ -2737,12 +2733,11 @@ public class ArithmeticOperators { /** - * Creates a new {@link AggregationExpression} that calculates the inverse - * tangent of of y / x, where y and x are the first and second values passed to - * the expression respectively. - * - * @param value anything ({@link Field field}, {@link AggregationExpression - * expression}, ...) that resolves to a numeric value. + * Creates a new {@link AggregationExpression} that calculates the inverse tangent of of y / x, where y and x are + * the first and second values passed to the expression respectively. + * + * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a + * numeric value. * @return new instance of {@link ATan2}. */ public ATan2 atan2of(String fieldReference) { @@ -2750,7 +2745,7 @@ public class ArithmeticOperators { Assert.notNull(fieldReference, "FieldReference must not be null!"); return new ATan2(append(Fields.field(fieldReference))); } - + /** * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in * {@link AngularUnit#RADIANS}. @@ -2760,21 +2755,20 @@ public class ArithmeticOperators { * @return new instance of {@link ATan2}. */ public ATan2 atan2of(AggregationExpression expression) { - + Assert.notNull(expression, "Expression must not be null!"); return new ATan2(append(expression)); } - + /** - * Creates a new {@link AggregationExpression} that calculates the inverse - * tangent of of y / x, where y and x are the first and second values passed to - * the expression respectively. - * + * Creates a new {@link AggregationExpression} that calculates the inverse tangent of of y / x, where y and x are + * the first and second values passed to the expression respectively. + * * @param value of type {@link Number} * @return new instance of {@link ATan2}. */ public ATan2 atan2of(Number value) { - + return new ATan2(append(value)); } @@ -2818,8 +2812,6 @@ public class ArithmeticOperators { * { $tanh : { $degreesToRadians : "$angle" } } * * - * . - * * @param fieldReference the name of the {@link Field field} that resolves to a numeric value. * @param unit the unit of measure used by the value of the given field. * @return new instance of {@link Tanh}. @@ -2888,11 +2880,12 @@ public class ArithmeticOperators { return "$tanh"; } } - + /** - * An {@link AggregationExpression expression} that calculates the inverse - * hyperbolic tangent of a value + * An {@link AggregationExpression expression} that calculates the inverse hyperbolic tangent of a value * + * @author Divya Srivastava + * @since 3.3 */ public static class ATanh extends AbstractAggregationExpression { @@ -2913,12 +2906,10 @@ public class ArithmeticOperators { } /** - * Creates a new {@link AggregationExpression} that calculates the inverse - * hyperbolic tangent of a value. + * Creates a new {@link AggregationExpression} that calculates the inverse hyperbolic tangent of a value. *

- * - * @param expression the {@link AggregationExpression expression} that resolves - * to a numeric value. + * + * @param expression the {@link AggregationExpression expression} that resolves to a numeric value. * @return new instance of {@link ATanh}. */ public static ATanh atanhOf(AggregationExpression expression) { @@ -2933,7 +2924,7 @@ public class ArithmeticOperators { * expression}, ...) that resolves to a numeric value. * @return new instance of {@link ATanh}. */ - public static ATanh atanhof(Object value) { + public static ATanh atanhOf(Object value) { return new ATanh(value); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperatorsUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperatorsUnitTests.java index 8a52a8a2f..84d228f75 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperatorsUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperatorsUnitTests.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; * @author Christoph Strobl * @author Mark Paluch * @author Mushtaq Ahmed + * @author Divya Srivastava */ class ArithmeticOperatorsUnitTests { @@ -86,8 +87,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3728 void rendersSin() { - assertThat(valueOf("angle").sin().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $sin : \"$angle\" }"); + assertThat(valueOf("angle").sin().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $sin : \"$angle\" }"); } @Test // GH-3728 @@ -100,8 +100,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3728 void rendersSinh() { - assertThat(valueOf("angle").sinh().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $sinh : \"$angle\" }"); + assertThat(valueOf("angle").sinh().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $sinh : \"$angle\" }"); } @Test // GH-3728 @@ -114,8 +113,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3710 void rendersCos() { - assertThat(valueOf("angle").cos().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $cos : \"$angle\" }"); + assertThat(valueOf("angle").cos().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $cos : \"$angle\" }"); } @Test // GH-3710 @@ -128,8 +126,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3710 void rendersCosh() { - assertThat(valueOf("angle").cosh().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $cosh : \"$angle\" }"); + assertThat(valueOf("angle").cosh().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $cosh : \"$angle\" }"); } @Test // GH-3710 @@ -142,8 +139,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3730 void rendersTan() { - assertThat(valueOf("angle").tan().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $tan : \"$angle\" }"); + assertThat(valueOf("angle").tan().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $tan : \"$angle\" }"); } @Test // GH-3730 @@ -156,8 +152,7 @@ class ArithmeticOperatorsUnitTests { @Test // GH-3730 void rendersTanh() { - assertThat(valueOf("angle").tanh().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $tanh : \"$angle\" }"); + assertThat(valueOf("angle").tanh().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $tanh : \"$angle\" }"); } @Test // GH-3730 @@ -166,28 +161,25 @@ class ArithmeticOperatorsUnitTests { assertThat(valueOf("angle").tanh(AngularUnit.DEGREES).toDocument(Aggregation.DEFAULT_CONTEXT)) .isEqualTo("{ $tanh : { $degreesToRadians : \"$angle\" } }"); } - - @Test // DATAMONGO - 3709 + + @Test // GH-3709 void rendersATan() { - - assertThat(valueOf("field").atan().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $atan : \"$field\" }"); + + assertThat(valueOf("field").atan().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $atan : \"$field\" }"); } - - @Test // DATAMONGO - 3709 + + @Test // GH-3709 void rendersATan2() { - + assertThat(valueOf("field1").atan2("field2").toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $atan2 : [ \"$field1\" , \"$field2\" ] }"); + .isEqualTo("{ $atan2 : [ \"$field1\" , \"$field2\" ] }"); } - - @Test // DATAMONGO - 3709 + + @Test // GH-3709 void rendersATanh() { - - assertThat(valueOf("field").atanh().toDocument(Aggregation.DEFAULT_CONTEXT)) - .isEqualTo("{ $atanh : \"$field\" }"); - } + assertThat(valueOf("field").atanh().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $atanh : \"$field\" }"); + } @Test // GH-3724 void rendersRand() { diff --git a/src/main/asciidoc/reference/aggregation-framework.adoc b/src/main/asciidoc/reference/aggregation-framework.adoc index 75ed41509..387a0acf6 100644 --- a/src/main/asciidoc/reference/aggregation-framework.adoc +++ b/src/main/asciidoc/reference/aggregation-framework.adoc @@ -85,7 +85,7 @@ At the time of this writing, we provide support for the following Aggregation Op | `addToSet`, `covariancePop`, `covarianceSamp`, `expMovingAvg`, `first`, `last`, `max`, `min`, `avg`, `push`, `sum`, `count` (+++*+++), `stdDevPop`, `stdDevSamp` | Arithmetic Aggregation Operators -| `abs`, `add` (+++*+++ via `plus`), `ceil`, `cos`, `cosh`, `derivative`, `divide`, `exp`, `floor`, `integral`, `ln`, `log`, `log10`, `mod`, `multiply`, `pow`, `round`, `sqrt`, `subtract` (+++*+++ via `minus`), `sin`, `sinh`, `tan`, `tanh`, `trunc` +| `abs`, `add` (+++*+++ via `plus`), `atan`, `atan2`, `atanh`, `ceil`, `cos`, `cosh`, `derivative`, `divide`, `exp`, `floor`, `integral`, `ln`, `log`, `log10`, `mod`, `multiply`, `pow`, `round`, `sqrt`, `subtract` (+++*+++ via `minus`), `sin`, `sinh`, `tan`, `tanh`, `trunc` | String Aggregation Operators | `concat`, `substr`, `toLower`, `toUpper`, `strcasecmp`, `indexOfBytes`, `indexOfCP`, `regexFind`, `regexFindAll`, `regexMatch`, `split`, `strLenBytes`, `strLenCP`, `substrCP`, `trim`, `ltrim`, `rtim`