@@ -575,6 +575,51 @@ public Sinh sinh(AngularDimension unit) {
575
575
return usesFieldRef () ? Sinh .sinhOf (fieldReference , unit ) : Sinh .sinhOf (expression , unit );
576
576
}
577
577
578
+ /**
579
+ * Creates new {@link AggregationExpression} that calculates the cosine of a numeric value given in
580
+ * {@link AngularDimension#RADIANS radians}.
581
+ *
582
+ * @return new instance of {@link Sin}.
583
+ * @since 3.3
584
+ */
585
+ public Cos cos () {
586
+ return cos (AngularDimension .RADIANS );
587
+ }
588
+
589
+ /**
590
+ * Creates new {@link AggregationExpression} that calculates the cosine of a numeric value in the given
591
+ * {@link AngularDimension unit}.
592
+ *
593
+ * @param unit the unit of measure.
594
+ * @return new instance of {@link Sin}.
595
+ * @since 3.3
596
+ */
597
+ public Cos cos (AngularDimension unit ) {
598
+ return usesFieldRef () ? Cos .cosOf (fieldReference , unit ) : Cos .cosOf (expression , unit );
599
+ }
600
+
601
+ /**
602
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value given in
603
+ * {@link AngularDimension#RADIANS radians}.
604
+ *
605
+ * @return new instance of {@link Sin}.
606
+ * @since 3.3
607
+ */
608
+ public Cosh cosh () {
609
+ return cosh (AngularDimension .RADIANS );
610
+ }
611
+
612
+ /**
613
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value.
614
+ *
615
+ * @param unit the unit of measure.
616
+ * @return new instance of {@link Sin}.
617
+ * @since 3.3
618
+ */
619
+ public Cosh cosh (AngularDimension unit ) {
620
+ return usesFieldRef () ? Cosh .coshOf (fieldReference , unit ) : Cosh .coshOf (expression , unit );
621
+ }
622
+
578
623
/**
579
624
* Creates new {@link AggregationExpression} that calculates the tangent of a numeric value given in
580
625
* {@link AngularDimension#RADIANS radians}.
@@ -1957,6 +2002,212 @@ protected String getMongoMethod() {
1957
2002
}
1958
2003
}
1959
2004
2005
+ /**
2006
+ * An {@link AggregationExpression expression} that calculates the cosine of a value that is measured in radians.
2007
+ *
2008
+ * @author Christoph Strobl
2009
+ * @since 3.3
2010
+ */
2011
+ public static class Cos extends AbstractAggregationExpression {
2012
+
2013
+ private Cos (Object value ) {
2014
+ super (value );
2015
+ }
2016
+
2017
+ /**
2018
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2019
+ * {@link AngularDimension#RADIANS radians}.
2020
+ * <p />
2021
+ * Use {@code cosOf("angle", DEGREES)} as shortcut for
2022
+ *
2023
+ * <pre>
2024
+ * { $cos : { $degreesToRadians : "$angle" } }
2025
+ * </pre>
2026
+ *
2027
+ * .
2028
+ *
2029
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2030
+ * @return new instance of {@link Cos}.
2031
+ */
2032
+ public static Cos cosOf (String fieldReference ) {
2033
+ return cosOf (fieldReference , AngularDimension .RADIANS );
2034
+ }
2035
+
2036
+ /**
2037
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2038
+ * {@link AngularDimension unit}.
2039
+ *
2040
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2041
+ * @param unit the unit of measure used by the value of the given field.
2042
+ * @return new instance of {@link Cos}.
2043
+ */
2044
+ public static Cos cosOf (String fieldReference , AngularDimension unit ) {
2045
+ return cos (Fields .field (fieldReference ), unit );
2046
+ }
2047
+
2048
+ /**
2049
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2050
+ * {@link AngularDimension#RADIANS}.
2051
+ *
2052
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2053
+ * @return new instance of {@link Cos}.
2054
+ */
2055
+ public static Cos cosOf (AggregationExpression expression ) {
2056
+ return cosOf (expression , AngularDimension .RADIANS );
2057
+ }
2058
+
2059
+ /**
2060
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2061
+ * {@link AngularDimension unit}.
2062
+ *
2063
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2064
+ * @param unit the unit of measure used by the value of the given field.
2065
+ * @return new instance of {@link Cos}.
2066
+ */
2067
+ public static Cos cosOf (AggregationExpression expression , AngularDimension unit ) {
2068
+ return cos (expression , unit );
2069
+ }
2070
+
2071
+ /**
2072
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2073
+ * {@link AngularDimension#RADIANS}.
2074
+ *
2075
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2076
+ * numeric value
2077
+ * @return new instance of {@link Cos}.
2078
+ */
2079
+ public static Cos cos (Object value ) {
2080
+ return cos (value , AngularDimension .RADIANS );
2081
+ }
2082
+
2083
+ /**
2084
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2085
+ * {@link AngularDimension unit}.
2086
+ *
2087
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2088
+ * numeric value.
2089
+ * @param unit the unit of measure used by the value of the given field.
2090
+ * @return new instance of {@link Cos}.
2091
+ */
2092
+ public static Cos cos (Object value , AngularDimension unit ) {
2093
+
2094
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2095
+ return new Cos (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2096
+ }
2097
+ return new Cos (value );
2098
+ }
2099
+
2100
+ @ Override
2101
+ protected String getMongoMethod () {
2102
+ return "$cos" ;
2103
+ }
2104
+ }
2105
+
2106
+ /**
2107
+ * An {@link AggregationExpression expression} that calculates the hyperbolic cosine of a value that is measured in
2108
+ * {@link AngularDimension#RADIANS}.
2109
+ *
2110
+ * @author Christoph Strobl
2111
+ * @since 3.3
2112
+ */
2113
+ public static class Cosh extends AbstractAggregationExpression {
2114
+
2115
+ private Cosh (Object value ) {
2116
+ super (value );
2117
+ }
2118
+
2119
+ /**
2120
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2121
+ * {@link AngularDimension#RADIANS}.
2122
+ *
2123
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2124
+ * @return new instance of {@link Cosh}.
2125
+ */
2126
+ public static Cosh coshOf (String fieldReference ) {
2127
+ return coshOf (fieldReference , AngularDimension .RADIANS );
2128
+ }
2129
+
2130
+ /**
2131
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2132
+ * the given {@link AngularDimension unit}.
2133
+ * <p />
2134
+ * Use {@code coshOf("angle", DEGREES)} as shortcut for
2135
+ *
2136
+ * <pre>
2137
+ * { $cosh : { $degreesToRadians : "$angle" } }
2138
+ * </pre>
2139
+ *
2140
+ * .
2141
+ *
2142
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2143
+ * @param unit the unit of measure used by the value of the given field.
2144
+ * @return new instance of {@link Cosh}.
2145
+ */
2146
+ public static Cosh coshOf (String fieldReference , AngularDimension unit ) {
2147
+ return cosh (Fields .field (fieldReference ), unit );
2148
+ }
2149
+
2150
+ /**
2151
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2152
+ * {@link AngularDimension#RADIANS}.
2153
+ * <p />
2154
+ * Use {@code sinhOf("angle", DEGREES)} as shortcut for eg.
2155
+ * {@code sinhOf(ConvertOperators.valueOf("angle").degreesToRadians())}.
2156
+ *
2157
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2158
+ * @return new instance of {@link Cosh}.
2159
+ */
2160
+ public static Cosh coshOf (AggregationExpression expression ) {
2161
+ return coshOf (expression , AngularDimension .RADIANS );
2162
+ }
2163
+
2164
+ /**
2165
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2166
+ * the given {@link AngularDimension unit}.
2167
+ *
2168
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2169
+ * @param unit the unit of measure used by the value of the given field.
2170
+ * @return new instance of {@link Cosh}.
2171
+ */
2172
+ public static Cosh coshOf (AggregationExpression expression , AngularDimension unit ) {
2173
+ return cosh (expression , unit );
2174
+ }
2175
+
2176
+ /**
2177
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2178
+ * {@link AngularDimension#RADIANS}.
2179
+ *
2180
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2181
+ * numeric value.
2182
+ * @return new instance of {@link Cosh}.
2183
+ */
2184
+ public static Cosh cosh (Object value ) {
2185
+ return cosh (value , AngularDimension .RADIANS );
2186
+ }
2187
+
2188
+ /**
2189
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2190
+ * the given {@link AngularDimension unit}.
2191
+ *
2192
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2193
+ * numeric value
2194
+ * @param unit the unit of measure used by the value of the given field.
2195
+ * @return new instance of {@link Cosh}.
2196
+ */
2197
+ public static Cosh cosh (Object value , AngularDimension unit ) {
2198
+
2199
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2200
+ return new Cosh (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2201
+ }
2202
+ return new Cosh (value );
2203
+ }
2204
+
2205
+ @ Override
2206
+ protected String getMongoMethod () {
2207
+ return "$cosh" ;
2208
+ }
2209
+ }
2210
+
1960
2211
/**
1961
2212
* An {@link AggregationExpression expression} that calculates the tangent of a value that is measured in radians.
1962
2213
*
0 commit comments