[jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] Trigonometric fns
- COS - COSH - COT - COTH - SIN - SINH
This commit is contained in:
parent
92ecc6788e
commit
014a292a8a
88
jOOQ/src/main/java/org/jooq/impl/Cos.java
Normal file
88
jOOQ/src/main/java/org/jooq/impl/Cos.java
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <code>COS</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Cos
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Cos(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_COS, allNotNull(NUMERIC, number));
|
||||
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(function(N_COS, getDataType(), number));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -37,36 +37,48 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.DSL.two;
|
||||
import static org.jooq.impl.Internal.iadd;
|
||||
import static org.jooq.impl.Internal.idiv;
|
||||
import static org.jooq.impl.Internal.imul;
|
||||
import static org.jooq.impl.Names.N_COSH;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>COSH</code> statement.
|
||||
*/
|
||||
final class Cosh extends AbstractField<BigDecimal> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Cosh
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> argument;
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Cosh(Field<? extends Number> argument) {
|
||||
super(N_COSH, SQLDataType.NUMERIC);
|
||||
Cosh(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_COSH, allNotNull(NUMERIC, number));
|
||||
|
||||
this.argument = argument;
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -91,16 +103,18 @@ final class Cosh extends AbstractField<BigDecimal> {
|
||||
case POSTGRES:
|
||||
ctx.visit(idiv(
|
||||
iadd(
|
||||
DSL.exp(imul(argument, two())),
|
||||
DSL.exp(imul(number, two())),
|
||||
one()
|
||||
),
|
||||
imul(DSL.exp(argument), two())
|
||||
imul(DSL.exp(number), two())
|
||||
));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(N_COSH).sql('(').visit(argument).sql(')');
|
||||
ctx.visit(N_COSH).sql('(').visit(number).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -37,32 +37,48 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Internal.idiv;
|
||||
import static org.jooq.impl.Names.N_COT;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>COT</code> statement.
|
||||
*/
|
||||
final class Cot extends AbstractField<BigDecimal> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Cot
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> argument;
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Cot(Field<? extends Number> argument) {
|
||||
super(N_COT, SQLDataType.NUMERIC);
|
||||
Cot(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_COT, allNotNull(NUMERIC, number));
|
||||
|
||||
this.argument = argument;
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -77,8 +93,10 @@ final class Cot extends AbstractField<BigDecimal> {
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(N_COT).sql('(').visit(argument).sql(')');
|
||||
ctx.visit(N_COT).sql('(').visit(number).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
91
jOOQ/src/main/java/org/jooq/impl/Coth.java
Normal file
91
jOOQ/src/main/java/org/jooq/impl/Coth.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <code>COTH</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Coth
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Coth(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_COTH, allNotNull(NUMERIC, number));
|
||||
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(idiv(
|
||||
iadd(DSL.exp(imul(number, two())), one()),
|
||||
isub(DSL.exp(imul(number, two())), one())
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -88,17 +88,11 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Internal.iadd;
|
||||
import static org.jooq.impl.Internal.idiv;
|
||||
import static org.jooq.impl.Internal.imul;
|
||||
import static org.jooq.impl.Internal.isub;
|
||||
import static org.jooq.impl.Keywords.K_CUBE;
|
||||
import static org.jooq.impl.Keywords.K_GROUPING_SETS;
|
||||
import static org.jooq.impl.Names.N_ABS;
|
||||
import static org.jooq.impl.Names.N_COS;
|
||||
import static org.jooq.impl.Names.N_IF;
|
||||
import static org.jooq.impl.Names.N_IIF;
|
||||
import static org.jooq.impl.Names.N_SIN;
|
||||
import static org.jooq.impl.Names.N_SYSTEM_TIME;
|
||||
import static org.jooq.impl.Names.N_TAN;
|
||||
import static org.jooq.impl.Names.N_VALUE;
|
||||
@ -138,7 +132,6 @@ import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -14953,6 +14946,78 @@ public class DSL {
|
||||
return new CharLength(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COS</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cos(Number number) {
|
||||
return new Cos(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COS</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cos(Field<? extends Number> number) {
|
||||
return new Cos(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COSH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cosh(Number number) {
|
||||
return new Cosh(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COSH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cosh(Field<? extends Number> number) {
|
||||
return new Cosh(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COT</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cot(Number number) {
|
||||
return new Cot(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COT</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cot(Field<? extends Number> number) {
|
||||
return new Cot(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COTH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> coth(Number number) {
|
||||
return new Coth(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>COTH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> coth(Field<? extends Number> number) {
|
||||
return new Coth(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DEG</code> function.
|
||||
*/
|
||||
@ -15634,6 +15699,42 @@ public class DSL {
|
||||
return new Sign(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SIN</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sin(Number number) {
|
||||
return new Sin(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SIN</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sin(Field<? extends Number> number) {
|
||||
return new Sin(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SINH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sinh(Number number) {
|
||||
return new Sinh(Tools.field(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SINH</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sinh(Field<? extends Number> number) {
|
||||
return new Sinh(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SPACE</code> function.
|
||||
*/
|
||||
@ -19966,52 +20067,6 @@ public class DSL {
|
||||
return new DefaultAggregateFunction<>(Term.ATAN2, SQLDataType.NUMERIC, Tools.nullSafe(x), Tools.nullSafe(y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cosine(field) function.
|
||||
*
|
||||
* @see #cos(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cos(Number value) {
|
||||
return cos(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cosine(field) function.
|
||||
* <p>
|
||||
* This renders the cos function where available:
|
||||
* <code><pre>cos([field])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cos(Field<? extends Number> field) {
|
||||
return function(N_COS, SQLDataType.NUMERIC, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sine(field) function.
|
||||
*
|
||||
* @see #sin(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sin(Number value) {
|
||||
return sin(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sine(field) function.
|
||||
* <p>
|
||||
* This renders the sin function where available:
|
||||
* <code><pre>sin([field])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sin(Field<? extends Number> field) {
|
||||
return function(N_SIN, SQLDataType.NUMERIC, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tangent(field) function.
|
||||
*
|
||||
@ -20035,78 +20090,6 @@ public class DSL {
|
||||
return function(N_TAN, SQLDataType.NUMERIC, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cotangent(field) function.
|
||||
*
|
||||
* @see #cot(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cot(Number value) {
|
||||
return cot(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cotangent(field) function.
|
||||
* <p>
|
||||
* This renders the cot function where available:
|
||||
* <code><pre>cot([field])</pre></code> ... or emulates it elsewhere using
|
||||
* sin and cos: <code><pre>cos([field]) / sin([field])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cot(Field<? extends Number> field) {
|
||||
return new Cot(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic sine function: sinh(field).
|
||||
*
|
||||
* @see #sinh(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sinh(Number value) {
|
||||
return sinh(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic sine function: sinh(field).
|
||||
* <p>
|
||||
* This renders the sinh function where available:
|
||||
* <code><pre>sinh([field])</pre></code> ... or emulates it elsewhere using
|
||||
* exp: <code><pre>(exp([field] * 2) - 1) / (exp([field] * 2))</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sinh(Field<? extends Number> field) {
|
||||
return new Sinh(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic cosine function: cosh(field).
|
||||
*
|
||||
* @see #cosh(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cosh(Number value) {
|
||||
return cosh(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic cosine function: cosh(field).
|
||||
* <p>
|
||||
* This renders the cosh function where available:
|
||||
* <code><pre>cosh([field])</pre></code> ... or emulates it elsewhere using
|
||||
* exp: <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2))</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> cosh(Field<? extends Number> field) {
|
||||
return new Cosh(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic tangent function: tanh(field).
|
||||
*
|
||||
@ -20132,33 +20115,6 @@ public class DSL {
|
||||
return new Tanh(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic cotangent function: coth(field).
|
||||
*
|
||||
* @see #coth(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> coth(Number value) {
|
||||
return coth(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hyperbolic cotangent function: coth(field).
|
||||
* <p>
|
||||
* This is not supported by any RDBMS, but emulated using exp exp:
|
||||
* <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2) - 1)</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> coth(Field<? extends Number> field) {
|
||||
field = Tools.nullSafe(field);
|
||||
return idiv(
|
||||
iadd(exp(imul(field, two())), one()),
|
||||
isub(exp(imul(field, two())), one())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ final class Names {
|
||||
static final Name N_COS = unquotedName("cos");
|
||||
static final Name N_COSH = unquotedName("cosh");
|
||||
static final Name N_COT = unquotedName("cot");
|
||||
static final Name N_COTH = unquotedName("coth");
|
||||
static final Name N_COUNT = unquotedName("count");
|
||||
static final Name N_COUNTSET = unquotedName("countset");
|
||||
static final Name N_CURRENT_BIGDATETIME = unquotedName("current_bigdatetime");
|
||||
|
||||
88
jOOQ/src/main/java/org/jooq/impl/Sin.java
Normal file
88
jOOQ/src/main/java/org/jooq/impl/Sin.java
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <code>SIN</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Sin
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Sin(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_SIN, allNotNull(NUMERIC, number));
|
||||
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(function(N_SIN, getDataType(), number));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -37,37 +37,48 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.DSL.two;
|
||||
import static org.jooq.impl.Internal.idiv;
|
||||
import static org.jooq.impl.Internal.imul;
|
||||
import static org.jooq.impl.Internal.isub;
|
||||
import static org.jooq.impl.Names.N_SINH;
|
||||
import static org.jooq.impl.SQLDataType.NUMERIC;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>SINH</code> statement.
|
||||
*/
|
||||
final class Sinh extends AbstractField<BigDecimal> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Sinh
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> argument;
|
||||
private final Field<? extends Number> number;
|
||||
|
||||
Sinh(Field<? extends Number> argument) {
|
||||
super(N_SINH, NUMERIC);
|
||||
Sinh(
|
||||
Field<? extends Number> number
|
||||
) {
|
||||
super(N_SINH, allNotNull(NUMERIC, number));
|
||||
|
||||
this.argument = argument;
|
||||
this.number = nullSafeNotNull(number, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -91,14 +102,16 @@ final class Sinh extends AbstractField<BigDecimal> {
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
ctx.visit(idiv(
|
||||
isub(DSL.exp(imul(argument, two())), one()),
|
||||
imul(DSL.exp(argument), two())
|
||||
isub(DSL.exp(imul(number, two())), one()),
|
||||
imul(DSL.exp(number), two())
|
||||
));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(N_SINH).sql('(').visit(argument).sql(')');
|
||||
ctx.visit(N_SINH).sql('(').visit(number).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user