@@ -719,6 +719,51 @@ public Sinh sinh(AngularDimension unit) {
719
719
return usesFieldRef () ? Sinh .sinhOf (fieldReference , unit ) : Sinh .sinhOf (expression , unit );
720
720
}
721
721
722
+ /**
723
+ * Creates new {@link AggregationExpression} that calculates the cosine of a numeric value given in
724
+ * {@link AngularDimension#RADIANS radians}.
725
+ *
726
+ * @return new instance of {@link Sin}.
727
+ * @since 3.3
728
+ */
729
+ public Cos cos () {
730
+ return cos (AngularDimension .RADIANS );
731
+ }
732
+
733
+ /**
734
+ * Creates new {@link AggregationExpression} that calculates the cosine of a numeric value in the given
735
+ * {@link AngularDimension unit}.
736
+ *
737
+ * @param unit the unit of measure.
738
+ * @return new instance of {@link Sin}.
739
+ * @since 3.3
740
+ */
741
+ public Cos cos (AngularDimension unit ) {
742
+ return usesFieldRef () ? Cos .cosOf (fieldReference , unit ) : Cos .cosOf (expression , unit );
743
+ }
744
+
745
+ /**
746
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value given in
747
+ * {@link AngularDimension#RADIANS radians}.
748
+ *
749
+ * @return new instance of {@link Sin}.
750
+ * @since 3.3
751
+ */
752
+ public Cosh cosh () {
753
+ return cosh (AngularDimension .RADIANS );
754
+ }
755
+
756
+ /**
757
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic cosine of a numeric value.
758
+ *
759
+ * @param unit the unit of measure.
760
+ * @return new instance of {@link Sin}.
761
+ * @since 3.3
762
+ */
763
+ public Cosh cosh (AngularDimension unit ) {
764
+ return usesFieldRef () ? Cosh .coshOf (fieldReference , unit ) : Cosh .coshOf (expression , unit );
765
+ }
766
+
722
767
/**
723
768
* Creates new {@link AggregationExpression} that calculates the tangent of a numeric value given in
724
769
* {@link AngularDimension#RADIANS radians}.
@@ -2199,6 +2244,212 @@ protected String getMongoMethod() {
2199
2244
}
2200
2245
}
2201
2246
2247
+ /**
2248
+ * An {@link AggregationExpression expression} that calculates the cosine of a value that is measured in radians.
2249
+ *
2250
+ * @author Christoph Strobl
2251
+ * @since 3.3
2252
+ */
2253
+ public static class Cos extends AbstractAggregationExpression {
2254
+
2255
+ private Cos (Object value ) {
2256
+ super (value );
2257
+ }
2258
+
2259
+ /**
2260
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2261
+ * {@link AngularDimension#RADIANS radians}.
2262
+ * <p />
2263
+ * Use {@code cosOf("angle", DEGREES)} as shortcut for
2264
+ *
2265
+ * <pre>
2266
+ * { $cos : { $degreesToRadians : "$angle" } }
2267
+ * </pre>
2268
+ *
2269
+ * .
2270
+ *
2271
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2272
+ * @return new instance of {@link Cos}.
2273
+ */
2274
+ public static Cos cosOf (String fieldReference ) {
2275
+ return cosOf (fieldReference , AngularDimension .RADIANS );
2276
+ }
2277
+
2278
+ /**
2279
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2280
+ * {@link AngularDimension unit}.
2281
+ *
2282
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2283
+ * @param unit the unit of measure used by the value of the given field.
2284
+ * @return new instance of {@link Cos}.
2285
+ */
2286
+ public static Cos cosOf (String fieldReference , AngularDimension unit ) {
2287
+ return cos (Fields .field (fieldReference ), unit );
2288
+ }
2289
+
2290
+ /**
2291
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2292
+ * {@link AngularDimension#RADIANS}.
2293
+ *
2294
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2295
+ * @return new instance of {@link Cos}.
2296
+ */
2297
+ public static Cos cosOf (AggregationExpression expression ) {
2298
+ return cosOf (expression , AngularDimension .RADIANS );
2299
+ }
2300
+
2301
+ /**
2302
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2303
+ * {@link AngularDimension unit}.
2304
+ *
2305
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2306
+ * @param unit the unit of measure used by the value of the given field.
2307
+ * @return new instance of {@link Cos}.
2308
+ */
2309
+ public static Cos cosOf (AggregationExpression expression , AngularDimension unit ) {
2310
+ return cos (expression , unit );
2311
+ }
2312
+
2313
+ /**
2314
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in
2315
+ * {@link AngularDimension#RADIANS}.
2316
+ *
2317
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2318
+ * numeric value
2319
+ * @return new instance of {@link Cos}.
2320
+ */
2321
+ public static Cos cos (Object value ) {
2322
+ return cos (value , AngularDimension .RADIANS );
2323
+ }
2324
+
2325
+ /**
2326
+ * Creates a new {@link AggregationExpression} that calculates the cosine of a value that is measured in the given
2327
+ * {@link AngularDimension unit}.
2328
+ *
2329
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2330
+ * numeric value.
2331
+ * @param unit the unit of measure used by the value of the given field.
2332
+ * @return new instance of {@link Cos}.
2333
+ */
2334
+ public static Cos cos (Object value , AngularDimension unit ) {
2335
+
2336
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2337
+ return new Cos (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2338
+ }
2339
+ return new Cos (value );
2340
+ }
2341
+
2342
+ @ Override
2343
+ protected String getMongoMethod () {
2344
+ return "$cos" ;
2345
+ }
2346
+ }
2347
+
2348
+ /**
2349
+ * An {@link AggregationExpression expression} that calculates the hyperbolic cosine of a value that is measured in
2350
+ * {@link AngularDimension#RADIANS}.
2351
+ *
2352
+ * @author Christoph Strobl
2353
+ * @since 3.3
2354
+ */
2355
+ public static class Cosh extends AbstractAggregationExpression {
2356
+
2357
+ private Cosh (Object value ) {
2358
+ super (value );
2359
+ }
2360
+
2361
+ /**
2362
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2363
+ * {@link AngularDimension#RADIANS}.
2364
+ *
2365
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2366
+ * @return new instance of {@link Cosh}.
2367
+ */
2368
+ public static Cosh coshOf (String fieldReference ) {
2369
+ return coshOf (fieldReference , AngularDimension .RADIANS );
2370
+ }
2371
+
2372
+ /**
2373
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2374
+ * the given {@link AngularDimension unit}.
2375
+ * <p />
2376
+ * Use {@code coshOf("angle", DEGREES)} as shortcut for
2377
+ *
2378
+ * <pre>
2379
+ * { $cosh : { $degreesToRadians : "$angle" } }
2380
+ * </pre>
2381
+ *
2382
+ * .
2383
+ *
2384
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2385
+ * @param unit the unit of measure used by the value of the given field.
2386
+ * @return new instance of {@link Cosh}.
2387
+ */
2388
+ public static Cosh coshOf (String fieldReference , AngularDimension unit ) {
2389
+ return cosh (Fields .field (fieldReference ), unit );
2390
+ }
2391
+
2392
+ /**
2393
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2394
+ * {@link AngularDimension#RADIANS}.
2395
+ * <p />
2396
+ * Use {@code sinhOf("angle", DEGREES)} as shortcut for eg.
2397
+ * {@code sinhOf(ConvertOperators.valueOf("angle").degreesToRadians())}.
2398
+ *
2399
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2400
+ * @return new instance of {@link Cosh}.
2401
+ */
2402
+ public static Cosh coshOf (AggregationExpression expression ) {
2403
+ return coshOf (expression , AngularDimension .RADIANS );
2404
+ }
2405
+
2406
+ /**
2407
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2408
+ * the given {@link AngularDimension unit}.
2409
+ *
2410
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2411
+ * @param unit the unit of measure used by the value of the given field.
2412
+ * @return new instance of {@link Cosh}.
2413
+ */
2414
+ public static Cosh coshOf (AggregationExpression expression , AngularDimension unit ) {
2415
+ return cosh (expression , unit );
2416
+ }
2417
+
2418
+ /**
2419
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2420
+ * {@link AngularDimension#RADIANS}.
2421
+ *
2422
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2423
+ * numeric value.
2424
+ * @return new instance of {@link Cosh}.
2425
+ */
2426
+ public static Cosh cosh (Object value ) {
2427
+ return cosh (value , AngularDimension .RADIANS );
2428
+ }
2429
+
2430
+ /**
2431
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic cosine of a value that is measured in
2432
+ * the given {@link AngularDimension unit}.
2433
+ *
2434
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2435
+ * numeric value
2436
+ * @param unit the unit of measure used by the value of the given field.
2437
+ * @return new instance of {@link Cosh}.
2438
+ */
2439
+ public static Cosh cosh (Object value , AngularDimension unit ) {
2440
+
2441
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2442
+ return new Cosh (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2443
+ }
2444
+ return new Cosh (value );
2445
+ }
2446
+
2447
+ @ Override
2448
+ protected String getMongoMethod () {
2449
+ return "$cosh" ;
2450
+ }
2451
+ }
2452
+
2202
2453
/**
2203
2454
* An {@link AggregationExpression expression} that calculates the tangent of a value that is measured in radians.
2204
2455
*
0 commit comments