Browse Source

Polishing.

Add author and since tags. Tweak Javadoc format.

See #3709
Original pull request: #3794.
pull/3802/head
Mark Paluch 4 years ago
parent
commit
8af904b81f
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 101
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperators.java
  2. 32
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ArithmeticOperatorsUnitTests.java
  3. 2
      src/main/asciidoc/reference/aggregation-framework.adoc

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

@ -717,7 +717,7 @@ public class ArithmeticOperators { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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,7 +784,7 @@ public class ArithmeticOperators { @@ -784,7 +784,7 @@ 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() {
@ -795,17 +795,19 @@ public class ArithmeticOperators { @@ -795,17 +795,19 @@ public class ArithmeticOperators {
* 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
* @return new instance of {@link ATan2}.
* @since 3.3
*/
public ATan2 atan2(Number value) {
@ -814,11 +816,12 @@ public class ArithmeticOperators { @@ -814,11 +816,12 @@ public class ArithmeticOperators {
}
/**
* 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
* @return new instance of {@link ATan2}.
* @since 3.3
*/
public ATan2 atan2(String fieldReference) {
@ -827,11 +830,12 @@ public class ArithmeticOperators { @@ -827,11 +830,12 @@ public class ArithmeticOperators {
}
/**
* 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
* @return new instance of {@link ATan2}.
* @since 3.3
*/
public ATan2 atan2(AggregationExpression expression) {
@ -848,6 +852,7 @@ public class ArithmeticOperators { @@ -848,6 +852,7 @@ public class ArithmeticOperators {
* 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 { @@ -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 { @@ -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 { @@ -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 { @@ -2357,8 +2362,6 @@ public class ArithmeticOperators {
* { $cos : { $degreesToRadians : "$angle" } }
* </pre>
*
* .
*
* @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 { @@ -2470,8 +2473,6 @@ public class ArithmeticOperators {
* { $cosh : { $degreesToRadians : "$angle" } }
* </pre>
*
* .
*
* @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 { @@ -2563,8 +2564,6 @@ public class ArithmeticOperators {
* { $tan : { $degreesToRadians : "$angle" } }
* </pre>
*
* .
*
* @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
* @return new instance of {@link Tan}.
*/
@ -2642,10 +2641,11 @@ public class ArithmeticOperators { @@ -2642,10 +2641,11 @@ public class ArithmeticOperators {
}
}
/**
* An {@link AggregationExpression expression} that calculates the inverse tangent of a value.
*
* @author Divya Srivastava
* @since 3.3
*/
public static class ATan extends AbstractAggregationExpression {
@ -2667,7 +2667,6 @@ public class ArithmeticOperators { @@ -2667,7 +2667,6 @@ public class ArithmeticOperators {
/**
* Creates a new {@link AggregationExpression} that calculates the inverse tangent of a value.
* <p />
*
* @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 { @@ -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);
}
@ -2694,10 +2693,11 @@ public class ArithmeticOperators { @@ -2694,10 +2693,11 @@ public class ArithmeticOperators {
}
/**
* 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 {
@ -2706,12 +2706,10 @@ public class ArithmeticOperators { @@ -2706,12 +2706,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.
* 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.
* @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 { @@ -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.
* 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.
* @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 { @@ -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.
* 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.
* @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) {
@ -2766,9 +2761,8 @@ public class ArithmeticOperators { @@ -2766,9 +2761,8 @@ 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.
* 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}.
@ -2818,8 +2812,6 @@ public class ArithmeticOperators { @@ -2818,8 +2812,6 @@ public class ArithmeticOperators {
* { $tanh : { $degreesToRadians : "$angle" } }
* </pre>
*
* .
*
* @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}.
@ -2890,9 +2882,10 @@ public class ArithmeticOperators { @@ -2890,9 +2882,10 @@ public class ArithmeticOperators {
}
/**
* 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 { @@ -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.
* <p />
*
* @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 { @@ -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);
}

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

@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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
@ -167,28 +162,25 @@ class ArithmeticOperatorsUnitTests { @@ -167,28 +162,25 @@ class ArithmeticOperatorsUnitTests {
.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\" ] }");
}
@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() {
assertThat(rand().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo(new Document("$rand", new Document()));

2
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 @@ -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`

Loading…
Cancel
Save