@@ -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 tangent 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 Tan tan () {
586
+ return tan (AngularDimension .RADIANS );
587
+ }
588
+
589
+ /**
590
+ * Creates new {@link AggregationExpression} that calculates the tangent 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 Tan tan (AngularDimension unit ) {
598
+ return usesFieldRef () ? Tan .tanOf (fieldReference , unit ) : Tan .tanOf (expression , unit );
599
+ }
600
+
601
+ /**
602
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic tangent 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 Tanh tanh () {
609
+ return tanh (AngularDimension .RADIANS );
610
+ }
611
+
612
+ /**
613
+ * Creates new {@link AggregationExpression} that calculates the hyperbolic tangent 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 Tanh tanh (AngularDimension unit ) {
620
+ return usesFieldRef () ? Tanh .tanhOf (fieldReference , unit ) : Tanh .tanhOf (expression , unit );
621
+ }
622
+
578
623
private boolean usesFieldRef () {
579
624
return fieldReference != null ;
580
625
}
@@ -1911,4 +1956,210 @@ protected String getMongoMethod() {
1911
1956
return "$sinh" ;
1912
1957
}
1913
1958
}
1959
+
1960
+ /**
1961
+ * An {@link AggregationExpression expression} that calculates the tangent of a value that is measured in radians.
1962
+ *
1963
+ * @author Christoph Strobl
1964
+ * @since 3.3
1965
+ */
1966
+ public static class Tan extends AbstractAggregationExpression {
1967
+
1968
+ private Tan (Object value ) {
1969
+ super (value );
1970
+ }
1971
+
1972
+ /**
1973
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in
1974
+ * {@link AngularDimension#RADIANS radians}.
1975
+ * <p />
1976
+ * Use {@code tanOf("angle", DEGREES)} as shortcut for
1977
+ *
1978
+ * <pre>
1979
+ * { $tan : { $degreesToRadians : "$angle" } }
1980
+ * </pre>
1981
+ *
1982
+ * .
1983
+ *
1984
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
1985
+ * @return new instance of {@link Tan}.
1986
+ */
1987
+ public static Tan tanOf (String fieldReference ) {
1988
+ return tanOf (fieldReference , AngularDimension .RADIANS );
1989
+ }
1990
+
1991
+ /**
1992
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in the given
1993
+ * {@link AngularDimension unit}.
1994
+ *
1995
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
1996
+ * @param unit the unit of measure used by the value of the given field.
1997
+ * @return new instance of {@link Tan}.
1998
+ */
1999
+ public static Tan tanOf (String fieldReference , AngularDimension unit ) {
2000
+ return tan (Fields .field (fieldReference ), unit );
2001
+ }
2002
+
2003
+ /**
2004
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in
2005
+ * {@link AngularDimension#RADIANS}.
2006
+ *
2007
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2008
+ * @return new instance of {@link Tan}.
2009
+ */
2010
+ public static Tan tanOf (AggregationExpression expression ) {
2011
+ return tanOf (expression , AngularDimension .RADIANS );
2012
+ }
2013
+
2014
+ /**
2015
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in the given
2016
+ * {@link AngularDimension unit}.
2017
+ *
2018
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2019
+ * @param unit the unit of measure used by the value of the given field.
2020
+ * @return new instance of {@link Tan}.
2021
+ */
2022
+ public static Tan tanOf (AggregationExpression expression , AngularDimension unit ) {
2023
+ return tan (expression , unit );
2024
+ }
2025
+
2026
+ /**
2027
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in
2028
+ * {@link AngularDimension#RADIANS}.
2029
+ *
2030
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2031
+ * numeric value
2032
+ * @return new instance of {@link Tan}.
2033
+ */
2034
+ public static Tan tan (Object value ) {
2035
+ return tan (value , AngularDimension .RADIANS );
2036
+ }
2037
+
2038
+ /**
2039
+ * Creates a new {@link AggregationExpression} that calculates the tangent of a value that is measured in the given
2040
+ * {@link AngularDimension unit}.
2041
+ *
2042
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2043
+ * numeric value.
2044
+ * @param unit the unit of measure used by the value of the given field.
2045
+ * @return new instance of {@link Tan}.
2046
+ */
2047
+ public static Tan tan (Object value , AngularDimension unit ) {
2048
+
2049
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2050
+ return new Tan (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2051
+ }
2052
+ return new Tan (value );
2053
+ }
2054
+
2055
+ @ Override
2056
+ protected String getMongoMethod () {
2057
+ return "$tan" ;
2058
+ }
2059
+ }
2060
+
2061
+ /**
2062
+ * An {@link AggregationExpression expression} that calculates the hyperbolic tangent of a value that is measured in
2063
+ * {@link AngularDimension#RADIANS}.
2064
+ *
2065
+ * @author Christoph Strobl
2066
+ * @since 3.3
2067
+ */
2068
+ public static class Tanh extends AbstractAggregationExpression {
2069
+
2070
+ private Tanh (Object value ) {
2071
+ super (value );
2072
+ }
2073
+
2074
+ /**
2075
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2076
+ * {@link AngularDimension#RADIANS}.
2077
+ *
2078
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2079
+ * @return new instance of {@link Tanh}.
2080
+ */
2081
+ public static Tanh tanhOf (String fieldReference ) {
2082
+ return tanhOf (fieldReference , AngularDimension .RADIANS );
2083
+ }
2084
+
2085
+ /**
2086
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2087
+ * the given {@link AngularDimension unit}.
2088
+ * <p />
2089
+ * Use {@code tanhOf("angle", DEGREES)} as shortcut for
2090
+ *
2091
+ * <pre>
2092
+ * { $tanh : { $degreesToRadians : "$angle" } }
2093
+ * </pre>
2094
+ *
2095
+ * .
2096
+ *
2097
+ * @param fieldReference the name of the {@link Field field} that resolves to a numeric value.
2098
+ * @param unit the unit of measure used by the value of the given field.
2099
+ * @return new instance of {@link Tanh}.
2100
+ */
2101
+ public static Tanh tanhOf (String fieldReference , AngularDimension unit ) {
2102
+ return tanh (Fields .field (fieldReference ), unit );
2103
+ }
2104
+
2105
+ /**
2106
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2107
+ * {@link AngularDimension#RADIANS}.
2108
+ * <p />
2109
+ * Use {@code sinhOf("angle", DEGREES)} as shortcut for eg.
2110
+ * {@code sinhOf(ConvertOperators.valueOf("angle").degreesToRadians())}.
2111
+ *
2112
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2113
+ * @return new instance of {@link Tanh}.
2114
+ */
2115
+ public static Tanh tanhOf (AggregationExpression expression ) {
2116
+ return tanhOf (expression , AngularDimension .RADIANS );
2117
+ }
2118
+
2119
+ /**
2120
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2121
+ * the given {@link AngularDimension unit}.
2122
+ *
2123
+ * @param expression the {@link AggregationExpression expression} that resolves to a numeric value.
2124
+ * @param unit the unit of measure used by the value of the given field.
2125
+ * @return new instance of {@link Tanh}.
2126
+ */
2127
+ public static Tanh tanhOf (AggregationExpression expression , AngularDimension unit ) {
2128
+ return tanh (expression , unit );
2129
+ }
2130
+
2131
+ /**
2132
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2133
+ * {@link AngularDimension#RADIANS}.
2134
+ *
2135
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2136
+ * numeric value.
2137
+ * @return new instance of {@link Tanh}.
2138
+ */
2139
+ public static Tanh tanh (Object value ) {
2140
+ return tanh (value , AngularDimension .RADIANS );
2141
+ }
2142
+
2143
+ /**
2144
+ * Creates a new {@link AggregationExpression} that calculates the hyperbolic tangent of a value that is measured in
2145
+ * the given {@link AngularDimension unit}.
2146
+ *
2147
+ * @param value anything ({@link Field field}, {@link AggregationExpression expression}, ...) that resolves to a
2148
+ * numeric value
2149
+ * @param unit the unit of measure used by the value of the given field.
2150
+ * @return new instance of {@link Tanh}.
2151
+ */
2152
+ public static Tanh tanh (Object value , AngularDimension unit ) {
2153
+
2154
+ if (ObjectUtils .nullSafeEquals (AngularDimension .DEGREES , unit )) {
2155
+ return new Tanh (ConvertOperators .DegreesToRadians .degreesToRadians (value ));
2156
+ }
2157
+ return new Tanh (value );
2158
+ }
2159
+
2160
+ @ Override
2161
+ protected String getMongoMethod () {
2162
+ return "$tanh" ;
2163
+ }
2164
+ }
1914
2165
}
0 commit comments