From c398201671bc7c9e06bd0dba1184643e1479a2f6 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Tue, 15 Dec 2020 10:13:47 +0100 Subject: [PATCH] [jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] ATAN2 --- jOOQ/src/main/java/org/jooq/impl/Atan2.java | 121 ++++++++++++++++++++ jOOQ/src/main/java/org/jooq/impl/DSL.java | 82 ++++++------- jOOQ/src/main/java/org/jooq/impl/Names.java | 2 + jOOQ/src/main/java/org/jooq/impl/Term.java | 15 --- 4 files changed, 159 insertions(+), 61 deletions(-) create mode 100644 jOOQ/src/main/java/org/jooq/impl/Atan2.java diff --git a/jOOQ/src/main/java/org/jooq/impl/Atan2.java b/jOOQ/src/main/java/org/jooq/impl/Atan2.java new file mode 100644 index 0000000000..a2f456efb2 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Atan2.java @@ -0,0 +1,121 @@ +/* + * 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 org.jooq.tools.*; + +import java.util.*; +import java.math.BigDecimal; + + +/** + * The ATAN2 statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Atan2 +extends + AbstractField +{ + + private static final long serialVersionUID = 1L; + + private final Field x; + private final Field y; + + Atan2( + Field x, + Field y + ) { + super(N_ATAN2, allNotNull(NUMERIC, x, y)); + + this.x = nullSafeNotNull(x, INTEGER); + this.y = nullSafeNotNull(y, INTEGER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + + + default: + ctx.visit(function(N_ATAN2, getDataType(), x, y)); + break; + } + } + + + + // ------------------------------------------------------------------------- + // The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof Atan2) { + return + StringUtils.equals(x, ((Atan2) that).x) && + StringUtils.equals(y, ((Atan2) that).y) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index d4ff2071ff..503bdc397a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -14924,6 +14924,42 @@ public class DSL { return new Ascii(string); } + /** + * The ATAN2 function. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static Field atan2(Number x, Number y) { + return new Atan2(Tools.field(x), Tools.field(y)); + } + + /** + * The ATAN2 function. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static Field atan2(Number x, Field y) { + return new Atan2(Tools.field(x), y); + } + + /** + * The ATAN2 function. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static Field atan2(Field x, Number y) { + return new Atan2(x, Tools.field(y)); + } + + /** + * The ATAN2 function. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static Field atan2(Field x, Field y) { + return new Atan2(x, y); + } + /** * The BIT_LENGTH function. *

@@ -20575,52 +20611,6 @@ public class DSL { return new Atan(Tools.nullSafe(field)); } - /** - * Get the atan2(field, y) function. - * - * @see #atan2(Field, Field) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) - public static Field atan2(Number x, Number y) { - return atan2(Tools.field(x), Tools.field(y)); - } - - /** - * Get the atan2(field, y) function. - * - * @see #atan2(Field, Field) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) - public static Field atan2(Number x, Field y) { - return atan2(Tools.field(x), Tools.nullSafe(y)); - } - - /** - * Get the atan2(field, y) function. - * - * @see #atan2(Field, Field) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) - public static Field atan2(Field x, Number y) { - return atan2(Tools.nullSafe(x), Tools.field(y)); - } - - /** - * Get the atan2(field, y) function. - *

- * This renders the atan2 or atn2 function where available: - *

atan2([x], [y]) or
-     * atn2([x], [y])
- */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) - public static Field atan2(Field x, Field y) { - return new DefaultAggregateFunction<>(Term.ATAN2, SQLDataType.NUMERIC, Tools.nullSafe(x), Tools.nullSafe(y)); - } - /** * Get the tangent(field) function. * diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 0e2a3b769f..1821c8f3f1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -67,7 +67,9 @@ final class Names { static final Name N_ASCII_VAL = unquotedName("ascii_val"); static final Name N_ASIN = unquotedName("asin"); static final Name N_ATAN = unquotedName("atan"); + static final Name N_ATAN2 = unquotedName("atan2"); static final Name N_ATN = unquotedName("atn"); + static final Name N_ATN2 = unquotedName("atn2"); static final Name N_BIT_COUNT = unquotedName("bit_count"); static final Name N_BIT_LENGTH = unquotedName("bit_length"); static final Name N_BOOL_AND = unquotedName("bool_and"); diff --git a/jOOQ/src/main/java/org/jooq/impl/Term.java b/jOOQ/src/main/java/org/jooq/impl/Term.java index 8f8d9734b0..3b2165bb81 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Term.java +++ b/jOOQ/src/main/java/org/jooq/impl/Term.java @@ -51,21 +51,6 @@ import org.jooq.SQLDialect; @Deprecated enum Term { - ATAN2 { - @Override - public String translate(SQLDialect dialect) { - - - - - - - - - - return "atan2"; - } - }, STDDEV_POP { @Override public String translate(SQLDialect dialect) {