From 5d2b412dde893e674cfc59baab09a18775122ba8 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sun, 27 Nov 2011 14:30:53 +0000 Subject: [PATCH] Restored pre-2.0 org.jooq.Field API for backwards-compatibility. This API will be removed later --- .../release/template/RELEASENOTES.txt | 8 +- jOOQ-test/src/Run.java | 77 ++ .../src/org/jooq/test/jOOQAbstractTest.java | 2 +- jOOQ-website/inc/RELEASENOTES.txt | 11 +- jOOQ/src/main/java/org/jooq/Field.java | 973 ++++++++++++++++++ .../java/org/jooq/impl/AbstractField.java | 676 ++++++++++++ jOOQ/src/main/java/org/jooq/impl/Cast.java | 5 +- jOOQ/src/main/java/org/jooq/impl/Ceil.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Cosh.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Cot.java | 4 +- jOOQ/src/main/java/org/jooq/impl/Euler.java | 3 +- .../main/java/org/jooq/impl/Expression.java | 5 +- jOOQ/src/main/java/org/jooq/impl/Floor.java | 3 +- .../src/main/java/org/jooq/impl/Greatest.java | 5 +- jOOQ/src/main/java/org/jooq/impl/Least.java | 5 +- jOOQ/src/main/java/org/jooq/impl/Ln.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Lpad.java | 7 +- jOOQ/src/main/java/org/jooq/impl/Pi.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Power.java | 4 +- jOOQ/src/main/java/org/jooq/impl/Repeat.java | 4 +- jOOQ/src/main/java/org/jooq/impl/Round.java | 14 +- jOOQ/src/main/java/org/jooq/impl/Rpad.java | 7 +- jOOQ/src/main/java/org/jooq/impl/Sinh.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Sqrt.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Tanh.java | 3 +- jOOQ/src/main/java/org/jooq/impl/Trim.java | 4 +- 26 files changed, 1770 insertions(+), 68 deletions(-) create mode 100644 jOOQ-test/src/Run.java diff --git a/jOOQ-release/release/template/RELEASENOTES.txt b/jOOQ-release/release/template/RELEASENOTES.txt index e5d0eca47a..627db8912a 100644 --- a/jOOQ-release/release/template/RELEASENOTES.txt +++ b/jOOQ-release/release/template/RELEASENOTES.txt @@ -30,7 +30,8 @@ Most important changes
trim(replace(NAME, " ", "_"))
Using static imports of Factory.*, jOOQ makes SQL look even - more like SQL + more like SQL. The current "postfix notation" is maintained for + backwards compatibility. - By default, jooq-codegen will now generate a "dynamic" meta model as opposed to the existing static one. Generated tables covariantly override the as(String) aliasing method, leading @@ -88,8 +89,9 @@ order to upgrade, please be aware of the following pitfalls: - The schema needs to be re-generated. - Much of the post-fix function notation is replaced by static - methods in the Factory. Today's org.jooq.Field API is not - maintained in jOOQ 2.0 + methods in the Factory. Today's org.jooq.Field API is + maintained in jOOQ 2.0, for backwards compatibility. It will + be removed, eventually, though. - Some Factory instance methods (such as val(), literal()) are now static. They are compatible, but may cause compiler warnings. diff --git a/jOOQ-test/src/Run.java b/jOOQ-test/src/Run.java new file mode 100644 index 0000000000..d89d13e840 --- /dev/null +++ b/jOOQ-test/src/Run.java @@ -0,0 +1,77 @@ +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.jooq.impl.Factory; +import org.jooq.util.oracle.OracleFactory; + +/** + * Copyright (c) 2009-2011, Lukas Eder, lukas.eder@gmail.com + * All rights reserved. + * + * This software is licensed to you under the Apache License, Version 2.0 + * (the "License"); You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * . Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * . Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * . Neither the name "jOOQ" nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +public class Run { + + /** + * @param args + * @throws SQLException + */ + public static void main(String[] args) throws SQLException { + Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "TEST", "TEST"); + Factory create = new OracleFactory(connection); + + System.out.println(create.fetch("with data as ("+ + " select 'Lukas' as employee,"+ + " 'SoftSkills' as company, "+ + " 80000 as salary, "+ + " 2007 as year "+ + " from dual"+ + " union all select 'Lukas', 'SoftSkills', 80000, 2008 from dual"+ + " union all select 'Lukas', 'SmartSoft', 90000, 2009 from dual"+ + " union all select 'Lukas', 'SmartSoft', 95000, 2010 from dual"+ + " union all select 'Lukas', 'jOOQ', 200000, 2011 from dual"+ + " union all select 'Lukas', 'jOOQ', 250000, 2012 from dual"+ + " union all select 'Tom', 'SoftSkills', 89000, 2007 from dual"+ + " union all select 'Tom', 'SoftSkills', 90000, 2008 from dual"+ + " union all select 'Tom', 'SoftSkills', 91000, 2009 from dual"+ + " union all select 'Tom', 'SmartSoft', 92000, 2010 from dual"+ + " union all select 'Tom', 'SmartSoft', 93000, 2011 from dual"+ + " union all select 'Tom', 'SmartSoft', 94000, 2012 from dual"+ + " )"+ + " select grouping_id(employee, company) id, company, employee, avg(salary)"+ + " from data"+ + " group by cube(employee, company)")); + } + +} diff --git a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java index a273d7ed4a..27e1219fec 100644 --- a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java +++ b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java @@ -1136,7 +1136,7 @@ public abstract class jOOQAbstractTest< // [#610] Collision-prone entities are only available in HSQLDB else if (getDialect() == HSQLDB) { - assertEquals(tables + 8, schema.getTables().size()); + assertEquals(tables + 9, schema.getTables().size()); } else { diff --git a/jOOQ-website/inc/RELEASENOTES.txt b/jOOQ-website/inc/RELEASENOTES.txt index fe7b562a6a..627db8912a 100644 --- a/jOOQ-website/inc/RELEASENOTES.txt +++ b/jOOQ-website/inc/RELEASENOTES.txt @@ -30,7 +30,8 @@ Most important changes
trim(replace(NAME, " ", "_"))
Using static imports of Factory.*, jOOQ makes SQL look even - more like SQL + more like SQL. The current "postfix notation" is maintained for + backwards compatibility. - By default, jooq-codegen will now generate a "dynamic" meta model as opposed to the existing static one. Generated tables covariantly override the as(String) aliasing method, leading @@ -76,7 +77,8 @@ sum(AMOUNT).over().partitionBy(ACCOUNT) - Sequences now also have a type - Unsigned number types are now supported in those databases that use them. Unsigned numbers are implemented in jOOU, a spin-off - open source project: + open source project. For convenience, this library is + "internalised" into jOOQ, to avoid adding a dependency http://code.google.com/p/joou/ @@ -87,8 +89,9 @@ order to upgrade, please be aware of the following pitfalls: - The schema needs to be re-generated. - Much of the post-fix function notation is replaced by static - methods in the Factory. Today's org.jooq.Field API is not - maintained in jOOQ 2.0 + methods in the Factory. Today's org.jooq.Field API is + maintained in jOOQ 2.0, for backwards compatibility. It will + be removed, eventually, though. - Some Factory instance methods (such as val(), literal()) are now static. They are compatible, but may cause compiler warnings. diff --git a/jOOQ/src/main/java/org/jooq/Field.java b/jOOQ/src/main/java/org/jooq/Field.java index 3f5f93fe09..3b0a717e64 100644 --- a/jOOQ/src/main/java/org/jooq/Field.java +++ b/jOOQ/src/main/java/org/jooq/Field.java @@ -36,9 +36,12 @@ package org.jooq; +import java.math.BigDecimal; import java.util.Collection; import java.util.Map; +import org.jooq.impl.Factory; + /** * A field used in tables and conditions * @@ -606,4 +609,974 @@ public interface Field extends NamedTypeProviderQueryPart, AliasProvider query); + // ------------------------------------------------------------------------ + // Pre-2.0 API. This API is maintained for backwards-compatibility. It will + // be removed in the future. Consider using equivalent methods from + // org.jooq.Factory + // ------------------------------------------------------------------------ + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sign(Field) + */ + Field sign(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#abs(Field) + */ + Field abs(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#round(Field) + */ + Field round(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#round(Field, int) + */ + Field round(int decimals); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#floor(Field) + */ + Field floor(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#ceil(Field) + */ + Field ceil(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sqrt(Field) + */ + Field sqrt(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#exp(Field) + */ + Field exp(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#ln(Field) + */ + Field ln(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#log(Field, int) + */ + Field log(int base); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#power(Field, Number) + */ + Field power(Number exponent); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#acos(Field) + */ + Field acos(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#asin(Field) + */ + Field asin(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#atan(Field) + */ + Field atan(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#atan2(Field, Number) + */ + Field atan2(Number y); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#atan2(Field, Field) + */ + Field atan2(Field y); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#cos(Field) + */ + Field cos(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sin(Field) + */ + Field sin(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#tan(Field) + */ + Field tan(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#cot(Field) + */ + Field cot(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sinh(Field) + */ + Field sinh(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#cosh(Field) + */ + Field cosh(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#tanh(Field) + */ + Field tanh(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#coth(Field) + */ + Field coth(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#deg(Field) + */ + Field deg(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rad(Field) + */ + Field rad(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#count(Field) + */ + Field count(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#countDistinct(Field) + */ + Field countDistinct(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#max(Field) + */ + Field max(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#min(Field) + */ + Field min(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sum(Field) + */ + Field sum(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#avg(Field) + */ + Field avg(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#median(Field) + */ + Field median(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#stddevPop(Field) + */ + Field stddevPop(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#stddevSamp(Field) + */ + Field stddevSamp(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#varPop(Field) + */ + Field varPop(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#varSamp(Field) + */ + Field varSamp(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#count(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep countOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#max(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep maxOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#min(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep minOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#sum(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep sumOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#avg(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep avgOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#firstValue(Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep firstValue(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lastValue(Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lastValue(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lead(Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lead(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lead(Field, int) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lead(int offset); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lead(Field, int, Object) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lead(int offset, T defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lead(Field, int, Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lead(int offset, Field defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lag(Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lag(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lag(Field, int) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lag(int offset); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lag(Field, int, Object) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lag(int offset, T defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lag(Field, int, Field) + * @see AggregateFunction#over() + */ + WindowIgnoreNullsStep lag(int offset, Field defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#stddevPop(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep stddevPopOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#stddevSamp(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep stddevSampOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#varPop(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep varPopOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#varSamp(Field) + * @see AggregateFunction#over() + */ + WindowPartitionByStep varSampOver(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#upper(Field) + */ + Field upper(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lower(Field) + */ + Field lower(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#trim(Field) + */ + Field trim(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rtrim(Field) + */ + Field rtrim(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#ltrim(Field) + */ + Field ltrim(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rpad(Field, Field) + */ + Field rpad(Field length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rpad(Field, int) + */ + Field rpad(int length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rpad(Field, Field, Field) + */ + Field rpad(Field length, Field character); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#rpad(Field, int, char) + */ + Field rpad(int length, char character); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lpad(Field, Field) + */ + Field lpad(Field length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lpad(Field, int) + */ + Field lpad(int length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lpad(Field, Field, Field) + */ + Field lpad(Field length, Field character); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#lpad(Field, int, char) + */ + Field lpad(int length, char character); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#repeat(Field, int) + */ + Field repeat(Number count); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#repeat(Field, Field) + */ + Field repeat(Field count); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#replace(Field, Field) + */ + Field replace(Field search); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#replace(Field, String) + */ + Field replace(String search); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#replace(Field, Field, Field) + */ + Field replace(Field search, Field replace); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#replace(Field, String, String) + */ + Field replace(String search, String replace); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#position(Field, String) + */ + Field position(String search); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#position(Field, Field) + */ + Field position(Field search); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#ascii(Field) + */ + Field ascii(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#concat(Field...) + */ + Field concat(Field... fields); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#concat(String...) + */ + Field concat(String... values); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#substring(Field, int) + */ + Field substring(int startingPosition); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#substring(Field, Field) + */ + Field substring(Field startingPosition); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#substring(Field, int, int) + */ + Field substring(int startingPosition, int length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#substring(Field, Field, Field) + */ + Field substring(Field startingPosition, Field length); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#length(Field) + */ + Field length(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#charLength(Field) + */ + Field charLength(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#bitLength(Field) + */ + Field bitLength(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#octetLength(Field) + */ + Field octetLength(); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#extract(Field, DatePart) + */ + Field extract(DatePart datePart); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#greatest(Field, Field...) + */ + Field greatest(T... others); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#greatest(Field, Field...) + */ + Field greatest(Field... others); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#least(Field, Field...) + */ + Field least(T... others); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#least(Field, Field...) + */ + Field least(Field... others); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nvl(Field, Object) + */ + Field nvl(T defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nvl(Field, Field) + */ + Field nvl(Field defaultValue); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nvl2(Field, Object, Object) + */ + Field nvl2(Z valueIfNotNull, Z valueIfNull); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nvl2(Field, Field, Field) + */ + Field nvl2(Field valueIfNotNull, Field valueIfNull); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nullif(Field, Object) + */ + Field nullif(T other); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#nullif(Field, Field) + */ + Field nullif(Field other); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#decode(Object, Object, Object) + */ + Field decode(T search, Z result); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#decode(Object, Object, Object, Object...) + */ + Field decode(T search, Z result, Object... more); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#decode(Field, Field, Field) + */ + Field decode(Field search, Field result); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#decode(Field, Field, Field, Field...) + */ + Field decode(Field search, Field result, Field... more); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#coalesce(Object, Object...) + */ + Field coalesce(T option, T... options); + + /** + * This method is part of the pre-2.0 API. This API is maintained for + * backwards-compatibility. It may be removed in the future. Consider using + * equivalent methods from {@link Factory} + * + * @see Factory#coalesce(Field, Field...) + */ + Field coalesce(Field option, Field... options); + } diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java index c32708e1cb..3447c595a5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java @@ -45,6 +45,8 @@ import static org.jooq.impl.Factory.trueCondition; import static org.jooq.impl.Factory.val; import static org.jooq.impl.Factory.vals; +import java.math.BigDecimal; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -59,11 +61,14 @@ import org.jooq.CaseWhenStep; import org.jooq.Comparator; import org.jooq.Condition; import org.jooq.DataType; +import org.jooq.DatePart; import org.jooq.Field; import org.jooq.RenderContext; import org.jooq.Select; import org.jooq.SortField; import org.jooq.SortOrder; +import org.jooq.WindowIgnoreNullsStep; +import org.jooq.WindowPartitionByStep; import org.jooq.tools.Convert; abstract class AbstractField extends AbstractNamedTypeProviderQueryPart implements Field { @@ -605,4 +610,675 @@ abstract class AbstractField extends AbstractNamedTypeProviderQueryPart im public final Condition greaterOrEqualAll(Select query) { return new SelectQueryAsSubQueryCondition(query, this, SubQueryOperator.GREATER_OR_EQUAL_ALL); } + + // ------------------------------------------------------------------------ + // Pre-2.0 API. This API is maintained for backwards-compatibility. It will + // be removed in the future. Consider using equivalent methods from + // org.jooq.Factory + // ------------------------------------------------------------------------ + + @SuppressWarnings("unchecked") + private final Field numeric() { + if (getDataType().isNumeric()) { + return (Field) this; + } + else { + return (Field) cast(BigDecimal.class); + } + } + + @SuppressWarnings("unchecked") + private final Field varchar() { + if (getDataType().isString()) { + return (Field) this; + } + else { + return cast(String.class); + } + } + + @SuppressWarnings("unchecked") + private final Field date() { + if (getDataType().isTemporal()) { + return (Field) this; + } + else { + return (Field) cast(Timestamp.class); + } + } + + @Override + @Deprecated + public final Field sign() { + return Factory.sign(numeric()); + } + + @SuppressWarnings("unchecked") + @Override + @Deprecated + public final Field abs() { + return (Field) Factory.abs(numeric()); + } + + @SuppressWarnings("unchecked") + @Override + @Deprecated + public final Field round() { + return (Field) Factory.round(numeric()); + } + + @SuppressWarnings("unchecked") + @Override + @Deprecated + public final Field round(int decimals) { + return (Field) Factory.round(numeric(), decimals); + } + + @SuppressWarnings("unchecked") + @Override + @Deprecated + public final Field floor() { + return (Field) Factory.floor(numeric()); + } + + @SuppressWarnings("unchecked") + @Override + @Deprecated + public final Field ceil() { + return (Field) Factory.ceil(numeric()); + } + + @Override + @Deprecated + public final Field sqrt() { + return Factory.sqrt(numeric()); + } + + @Override + @Deprecated + public final Field exp() { + return Factory.exp(numeric()); + } + + @Override + @Deprecated + public final Field ln() { + return Factory.ln(numeric()); + } + + @Override + @Deprecated + public final Field log(int base) { + return Factory.log(numeric(), base); + } + + @Override + @Deprecated + public final Field power(Number exponent) { + return Factory.power(numeric(), exponent); + } + + @Override + @Deprecated + public final Field acos() { + return Factory.acos(numeric()); + } + + @Override + @Deprecated + public final Field asin() { + return Factory.asin(numeric()); + } + + @Override + @Deprecated + public final Field atan() { + return Factory.atan(numeric()); + } + + @Override + @Deprecated + public final Field atan2(Number y) { + return Factory.atan2(numeric(), y); + } + + @Override + @Deprecated + public final Field atan2(Field y) { + return Factory.atan2(numeric(), y); + } + + @Override + @Deprecated + public final Field cos() { + return Factory.cos(numeric()); + } + + @Override + @Deprecated + public final Field sin() { + return Factory.sin(numeric()); + } + + @Override + @Deprecated + public final Field tan() { + return Factory.tan(numeric()); + } + + @Override + @Deprecated + public final Field cot() { + return Factory.cot(numeric()); + } + + @Override + @Deprecated + public final Field sinh() { + return Factory.sinh(numeric()); + } + + @Override + @Deprecated + public final Field cosh() { + return Factory.cosh(numeric()); + } + + @Override + @Deprecated + public final Field tanh() { + return Factory.tanh(numeric()); + } + + @Override + @Deprecated + public final Field coth() { + return Factory.coth(numeric()); + } + + @Override + @Deprecated + public final Field deg() { + return Factory.deg(numeric()); + } + + @Override + @Deprecated + public final Field rad() { + return Factory.rad(numeric()); + } + + @Override + @Deprecated + public final Field count() { + return Factory.count(this); + } + + @Override + @Deprecated + public final Field countDistinct() { + return Factory.countDistinct(this); + } + + @Override + @Deprecated + public final Field max() { + return Factory.max(this); + } + + @Override + @Deprecated + public final Field min() { + return Factory.min(this); + } + + @Override + @Deprecated + public final Field sum() { + return Factory.sum(numeric()); + } + + @Override + @Deprecated + public final Field avg() { + return Factory.avg(numeric()); + } + + @Override + @Deprecated + public final Field median() { + return Factory.median(numeric()); + } + + @Override + @Deprecated + public final Field stddevPop() { + return Factory.stddevPop(numeric()); + } + + @Override + @Deprecated + public final Field stddevSamp() { + return Factory.stddevSamp(numeric()); + } + + @Override + @Deprecated + public final Field varPop() { + return Factory.varPop(numeric()); + } + + @Override + @Deprecated + public final Field varSamp() { + return Factory.varSamp(numeric()); + } + + @Override + @Deprecated + public final WindowPartitionByStep countOver() { + return Factory.count(this).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep maxOver() { + return Factory.max(this).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep minOver() { + return Factory.min(this).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep sumOver() { + return Factory.sum(numeric()).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep avgOver() { + return Factory.avg(numeric()).over(); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep firstValue() { + return Factory.firstValue(this); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lastValue() { + return Factory.lastValue(this); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lead() { + return Factory.lead(this); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lead(int offset) { + return Factory.lead(this, offset); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lead(int offset, T defaultValue) { + return Factory.lead(this, offset, defaultValue); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lead(int offset, Field defaultValue) { + return Factory.lead(this, offset, defaultValue); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lag() { + return Factory.lag(this); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lag(int offset) { + return Factory.lag(this, offset); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lag(int offset, T defaultValue) { + return Factory.lag(this, offset, defaultValue); + } + + @Override + @Deprecated + public final WindowIgnoreNullsStep lag(int offset, Field defaultValue) { + return Factory.lag(this, offset, defaultValue); + } + + @Override + @Deprecated + public final WindowPartitionByStep stddevPopOver() { + return Factory.stddevPop(numeric()).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep stddevSampOver() { + return Factory.stddevSamp(numeric()).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep varPopOver() { + return Factory.varPop(numeric()).over(); + } + + @Override + @Deprecated + public final WindowPartitionByStep varSampOver() { + return Factory.varSamp(numeric()).over(); + } + + @Override + @Deprecated + public final Field upper() { + return Factory.upper(varchar()); + } + + @Override + @Deprecated + public final Field lower() { + return Factory.lower(varchar()); + } + + @Override + @Deprecated + public final Field trim() { + return Factory.trim(varchar()); + } + + @Override + @Deprecated + public final Field rtrim() { + return Factory.rtrim(varchar()); + } + + @Override + @Deprecated + public final Field ltrim() { + return Factory.ltrim(varchar()); + } + + @Override + @Deprecated + public final Field rpad(Field length) { + return Factory.rpad(varchar(), length); + } + + @Override + @Deprecated + public final Field rpad(int length) { + return Factory.rpad(varchar(), length); + } + + @Override + @Deprecated + public final Field rpad(Field length, Field character) { + return Factory.rpad(varchar(), length, character); + } + + @Override + @Deprecated + public final Field rpad(int length, char character) { + return Factory.rpad(varchar(), length, character); + } + + @Override + @Deprecated + public final Field lpad(Field length) { + return Factory.lpad(varchar(), length); + } + + @Override + @Deprecated + public final Field lpad(int length) { + return Factory.lpad(varchar(), length); + } + + @Override + @Deprecated + public final Field lpad(Field length, Field character) { + return Factory.lpad(varchar(), length, character); + } + + @Override + @Deprecated + public final Field lpad(int length, char character) { + return Factory.lpad(varchar(), length, character); + } + + @Override + @Deprecated + public final Field repeat(Number count) { + return Factory.repeat(varchar(), count == null ? 0 : count.intValue()); + } + + @Override + @Deprecated + public final Field repeat(Field count) { + return Factory.repeat(varchar(), count); + } + + @Override + @Deprecated + public final Field replace(Field search) { + return Factory.replace(varchar(), search); + } + + @Override + @Deprecated + public final Field replace(String search) { + return Factory.replace(varchar(), search); + } + + @Override + @Deprecated + public final Field replace(Field search, Field replace) { + return Factory.replace(varchar(), search, replace); + } + + @Override + @Deprecated + public final Field replace(String search, String replace) { + return Factory.replace(varchar(), search, replace); + } + + @Override + @Deprecated + public final Field position(String search) { + return Factory.position(varchar(), search); + } + + @Override + @Deprecated + public final Field position(Field search) { + return Factory.position(varchar(), search); + } + + @Override + @Deprecated + public final Field ascii() { + return Factory.ascii(varchar()); + } + + @Override + @Deprecated + public final Field concat(Field... fields) { + return Factory.concat(Util.combine(this, fields)); + } + + @Override + @Deprecated + public final Field concat(String... values) { + return Factory.concat(Util.combine(this, vals((Object[]) values).toArray(new Field[0]))); + } + + @Override + @Deprecated + public final Field substring(int startingPosition) { + return Factory.substring(varchar(), startingPosition); + } + + @Override + @Deprecated + public final Field substring(Field startingPosition) { + return Factory.substring(varchar(), startingPosition); + } + + @Override + @Deprecated + public final Field substring(int startingPosition, int length) { + return Factory.substring(varchar(), startingPosition, length); + } + + @Override + @Deprecated + public final Field substring(Field startingPosition, Field length) { + return Factory.substring(varchar(), startingPosition, length); + } + + @Override + @Deprecated + public final Field length() { + return Factory.length(varchar()); + } + + @Override + @Deprecated + public final Field charLength() { + return Factory.charLength(varchar()); + } + + @Override + @Deprecated + public final Field bitLength() { + return Factory.bitLength(varchar()); + } + + @Override + @Deprecated + public final Field octetLength() { + return Factory.octetLength(varchar()); + } + + @Override + @Deprecated + public final Field extract(DatePart datePart) { + return Factory.extract(date(), datePart); + } + + @Override + @Deprecated + public final Field greatest(T... others) { + return Factory.greatest(this, vals(others).toArray(new Field[0])); + } + + @Override + @Deprecated + public final Field greatest(Field... others) { + return Factory.greatest(this, others); + } + + @Override + @Deprecated + public final Field least(T... others) { + return Factory.least(this, vals(others).toArray(new Field[0])); + } + + @Override + @Deprecated + public final Field least(Field... others) { + return Factory.least(this, others); + } + + @Override + @Deprecated + public final Field nvl(T defaultValue) { + return Factory.nvl(this, defaultValue); + } + + @Override + @Deprecated + public final Field nvl(Field defaultValue) { + return Factory.nvl(this, defaultValue); + } + + @Override + @Deprecated + public final Field nvl2(Z valueIfNotNull, Z valueIfNull) { + return Factory.nvl2(this, valueIfNotNull, valueIfNull); + } + + @Override + @Deprecated + public final Field nvl2(Field valueIfNotNull, Field valueIfNull) { + return Factory.nvl2(this, valueIfNotNull, valueIfNull); + } + + @Override + @Deprecated + public final Field nullif(T other) { + return Factory.nullif(this, other); + } + + @Override + @Deprecated + public final Field nullif(Field other) { + return Factory.nullif(this, other); + } + + @Override + @Deprecated + public final Field decode(T search, Z result) { + return Factory.decode(this, search, result); + } + + @Override + @Deprecated + public final Field decode(T search, Z result, Object... more) { + return Factory.decode(this, search, result, more); + } + + @Override + @Deprecated + public final Field decode(Field search, Field result) { + return Factory.decode(this, search, result); + } + + @Override + @Deprecated + public final Field decode(Field search, Field result, Field... more) { + return Factory.decode(this, search, result, more); + } + + @Override + @Deprecated + public final Field coalesce(T option, T... options) { + return Factory.coalesce(this, Util.combine(val(option), vals(options).toArray(new Field[0]))); + } + + @Override + @Deprecated + public final Field coalesce(Field option, Field... options) { + return Factory.coalesce(this, Util.combine(option, options)); + } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Cast.java b/jOOQ/src/main/java/org/jooq/impl/Cast.java index d508cde9e2..bb0ed53761 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Cast.java +++ b/jOOQ/src/main/java/org/jooq/impl/Cast.java @@ -37,7 +37,6 @@ package org.jooq.impl; import static java.util.Arrays.asList; import static org.jooq.impl.Factory.literal; -import static org.jooq.impl.Factory.lower; import static org.jooq.impl.SQLDataType.BOOLEAN; import static org.jooq.impl.SQLDataType.DOUBLE; import static org.jooq.impl.SQLDataType.FLOAT; @@ -153,8 +152,8 @@ class Cast extends AbstractField { // [#859] '0', 'f', 'false' => false, null => null, all else is true return Factory.decode().when(s.equal(literal("'0'")), literal(false)) - .when(lower(s).equal(literal("'false'")), literal(false)) - .when(lower(s).equal(literal("'f'")), literal(false)) + .when(Factory.lower(s).equal(literal("'false'")), literal(false)) + .when(Factory.lower(s).equal(literal("'f'")), literal(false)) .when(s.isNull(), literal((Boolean) null)) .otherwise(literal(true)); } diff --git a/jOOQ/src/main/java/org/jooq/impl/Ceil.java b/jOOQ/src/main/java/org/jooq/impl/Ceil.java index fff5e86c40..177da6d7b7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Ceil.java +++ b/jOOQ/src/main/java/org/jooq/impl/Ceil.java @@ -36,7 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.round; import org.jooq.Configuration; import org.jooq.Field; @@ -65,7 +64,7 @@ class Ceil extends AbstractFunction { // evaluate "ceil" if unavailable case SQLITE: - return round(argument.add(0.499999999999999)); + return Factory.round(argument.add(0.499999999999999)); case ASE: case H2: diff --git a/jOOQ/src/main/java/org/jooq/impl/Cosh.java b/jOOQ/src/main/java/org/jooq/impl/Cosh.java index 6f63a6a11f..53d582f514 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Cosh.java +++ b/jOOQ/src/main/java/org/jooq/impl/Cosh.java @@ -35,7 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.exp; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.one; import static org.jooq.impl.Factory.two; @@ -73,7 +72,7 @@ class Cosh extends AbstractFunction { case POSTGRES: case SQLSERVER: case SYBASE: - return exp(argument.mul(two())).add(one()).div(exp(argument).mul(two())); + return Factory.exp(argument.mul(two())).add(one()).div(Factory.exp(argument).mul(two())); default: return function("cosh", SQLDataType.NUMERIC, argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Cot.java b/jOOQ/src/main/java/org/jooq/impl/Cot.java index 0db08695ed..bd8924ab55 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Cot.java +++ b/jOOQ/src/main/java/org/jooq/impl/Cot.java @@ -35,9 +35,7 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.cos; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.sin; import java.math.BigDecimal; @@ -67,7 +65,7 @@ class Cot extends AbstractFunction { switch (configuration.getDialect()) { case INGRES: case ORACLE: - return cos(argument).div(sin(argument)); + return Factory.cos(argument).div(Factory.sin(argument)); default: return function("cot", SQLDataType.NUMERIC, argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Euler.java b/jOOQ/src/main/java/org/jooq/impl/Euler.java index 851d654c73..46c1e13e30 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Euler.java +++ b/jOOQ/src/main/java/org/jooq/impl/Euler.java @@ -35,7 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.exp; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.literal; import static org.jooq.impl.Factory.one; @@ -73,7 +72,7 @@ class Euler extends AbstractFunction { case POSTGRES: case SQLSERVER: case SYBASE: - return exp(one()); + return Factory.exp(one()); case SQLITE: return literal(Math.E, BigDecimal.class); diff --git a/jOOQ/src/main/java/org/jooq/impl/Expression.java b/jOOQ/src/main/java/org/jooq/impl/Expression.java index 2503208396..2a1bef8a32 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Expression.java +++ b/jOOQ/src/main/java/org/jooq/impl/Expression.java @@ -60,7 +60,6 @@ import static org.jooq.impl.Factory.bitOr; import static org.jooq.impl.Factory.bitXor; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.literal; -import static org.jooq.impl.Factory.power; import java.util.Arrays; import java.util.List; @@ -142,10 +141,10 @@ class Expression extends AbstractFunction { // Many dialects don't support shifts. Use multiplication/division instead else if (SHL == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect)) { - return lhs.mul(power(literal(2), rhsAsNumber())); + return lhs.mul(Factory.power(literal(2), rhsAsNumber())); } else if (SHR == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect)) { - return lhs.div(power(literal(2), rhsAsNumber())); + return lhs.div(Factory.power(literal(2), rhsAsNumber())); } // These operators are not supported in any dialect diff --git a/jOOQ/src/main/java/org/jooq/impl/Floor.java b/jOOQ/src/main/java/org/jooq/impl/Floor.java index 0910920dc7..920f47b243 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Floor.java +++ b/jOOQ/src/main/java/org/jooq/impl/Floor.java @@ -36,7 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.round; import org.jooq.Configuration; import org.jooq.Field; @@ -65,7 +64,7 @@ class Floor extends AbstractFunction { // evaluate "floor" if unavailable case SQLITE: - return round(argument.sub(0.499999999999999)); + return Factory.round(argument.sub(0.499999999999999)); default: return function("floor", getDataType(), argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Greatest.java b/jOOQ/src/main/java/org/jooq/impl/Greatest.java index 1b42252788..a16a57ddf3 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Greatest.java +++ b/jOOQ/src/main/java/org/jooq/impl/Greatest.java @@ -36,7 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.greatest; import org.jooq.Configuration; import org.jooq.DataType; @@ -81,8 +80,8 @@ class Greatest extends AbstractFunction { System.arraycopy(getArguments(), 2, remaining, 0, remaining.length); return Factory.decode() - .when(first.greaterThan(other), greatest(first, remaining)) - .otherwise(greatest(other, remaining)); + .when(first.greaterThan(other), Factory.greatest(first, remaining)) + .otherwise(Factory.greatest(other, remaining)); } else { return Factory.decode() diff --git a/jOOQ/src/main/java/org/jooq/impl/Least.java b/jOOQ/src/main/java/org/jooq/impl/Least.java index c54edf42fd..6cf2123270 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Least.java +++ b/jOOQ/src/main/java/org/jooq/impl/Least.java @@ -36,7 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.least; import org.jooq.Configuration; import org.jooq.DataType; @@ -81,8 +80,8 @@ class Least extends AbstractFunction { System.arraycopy(getArguments(), 2, remaining, 0, remaining.length); return Factory.decode() - .when(first.lessThan(other), least(first, remaining)) - .otherwise(least(other, remaining)); + .when(first.lessThan(other), Factory.least(first, remaining)) + .otherwise(Factory.least(other, remaining)); } else { return Factory.decode() diff --git a/jOOQ/src/main/java/org/jooq/impl/Ln.java b/jOOQ/src/main/java/org/jooq/impl/Ln.java index ebb8ca6687..ecdedeaa65 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Ln.java +++ b/jOOQ/src/main/java/org/jooq/impl/Ln.java @@ -37,7 +37,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.literal; -import static org.jooq.impl.Factory.ln; import java.math.BigDecimal; @@ -91,7 +90,7 @@ class Ln extends AbstractFunction { case INGRES: case SQLSERVER: case SYBASE: - return ln(argument).div(ln(literal(base))); + return Factory.ln(argument).div(Factory.ln(literal(base))); default: return function("log", SQLDataType.NUMERIC, literal(base), argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Lpad.java b/jOOQ/src/main/java/org/jooq/impl/Lpad.java index b25c4bc61a..02c0d72645 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Lpad.java +++ b/jOOQ/src/main/java/org/jooq/impl/Lpad.java @@ -35,10 +35,7 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.concat; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.length; -import static org.jooq.impl.Factory.repeat; import static org.jooq.impl.Factory.val; import org.jooq.Configuration; @@ -78,10 +75,10 @@ class Lpad extends AbstractFunction { case SQLSERVER: case SYBASE: { if (character == null) { - return concat(repeat(" ", length.sub(length(field))), field); + return Factory.concat(Factory.repeat(" ", length.sub(Factory.length(field))), field); } else { - return concat(repeat(character, length.sub(length(field))), field); + return Factory.concat(Factory.repeat(character, length.sub(Factory.length(field))), field); } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Pi.java b/jOOQ/src/main/java/org/jooq/impl/Pi.java index 3e972ad7c8..0e9ee35b0c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Pi.java +++ b/jOOQ/src/main/java/org/jooq/impl/Pi.java @@ -35,7 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.asin; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.literal; import static org.jooq.impl.Factory.one; @@ -65,7 +64,7 @@ class Pi extends AbstractFunction { switch (configuration.getDialect()) { case DB2: case ORACLE: - return asin(one()).mul(two()); + return Factory.asin(one()).mul(two()); case SQLITE: return literal(Math.PI, BigDecimal.class); diff --git a/jOOQ/src/main/java/org/jooq/impl/Power.java b/jOOQ/src/main/java/org/jooq/impl/Power.java index 5e4abc5e1d..2179f777e4 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Power.java +++ b/jOOQ/src/main/java/org/jooq/impl/Power.java @@ -35,9 +35,7 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.exp; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.ln; import java.math.BigDecimal; @@ -69,7 +67,7 @@ class Power extends AbstractFunction { switch (configuration.getDialect()) { case DERBY: case SQLITE: - return exp(ln(arg1).mul(arg2)); + return Factory.exp(Factory.ln(arg1).mul(arg2)); default: return function("power", SQLDataType.NUMERIC, getArguments()); diff --git a/jOOQ/src/main/java/org/jooq/impl/Repeat.java b/jOOQ/src/main/java/org/jooq/impl/Repeat.java index 88adbe39fb..0fb8afbb2f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Repeat.java +++ b/jOOQ/src/main/java/org/jooq/impl/Repeat.java @@ -36,8 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.length; -import static org.jooq.impl.Factory.rpad; import org.jooq.Configuration; import org.jooq.Field; @@ -67,7 +65,7 @@ class Repeat extends AbstractFunction { switch (configuration.getDialect()) { case INGRES: case ORACLE: - return rpad(string, length(string).mul(count), string); + return Factory.rpad(string, Factory.length(string).mul(count), string); case ASE: case SQLSERVER: diff --git a/jOOQ/src/main/java/org/jooq/impl/Round.java b/jOOQ/src/main/java/org/jooq/impl/Round.java index 9bc2c115f8..52621c5e80 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Round.java +++ b/jOOQ/src/main/java/org/jooq/impl/Round.java @@ -35,8 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.ceil; -import static org.jooq.impl.Factory.floor; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.val; @@ -78,18 +76,18 @@ class Round extends AbstractFunction { case DERBY: { if (decimals == 0) { return Factory.decode() - .when(argument.sub(floor(argument)) - .lessThan((T) Double.valueOf(0.5)), floor(argument)) - .otherwise(ceil(argument)); + .when(argument.sub(Factory.floor(argument)) + .lessThan((T) Double.valueOf(0.5)), Factory.floor(argument)) + .otherwise(Factory.ceil(argument)); } else { Field factor = Factory.val(BigDecimal.ONE.movePointRight(decimals)); Field mul = argument.mul(factor); return Factory.decode() - .when(mul.sub(floor(mul)) - .lessThan((T) Double.valueOf(0.5)), floor(mul).div(factor)) - .otherwise(ceil(mul).div(factor)); + .when(mul.sub(Factory.floor(mul)) + .lessThan((T) Double.valueOf(0.5)), Factory.floor(mul).div(factor)) + .otherwise(Factory.ceil(mul).div(factor)); } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Rpad.java b/jOOQ/src/main/java/org/jooq/impl/Rpad.java index 0e2613a7b8..cb6340b9fa 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Rpad.java +++ b/jOOQ/src/main/java/org/jooq/impl/Rpad.java @@ -35,10 +35,7 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.concat; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.length; -import static org.jooq.impl.Factory.repeat; import static org.jooq.impl.Factory.val; import org.jooq.Configuration; @@ -78,10 +75,10 @@ class Rpad extends AbstractFunction { case SQLSERVER: case SYBASE: { if (character == null) { - return concat(field, repeat(" ", length.sub(length(field)))); + return Factory.concat(field, Factory.repeat(" ", length.sub(Factory.length(field)))); } else { - return concat(field, repeat(character, length.sub(length(field)))); + return Factory.concat(field, Factory.repeat(character, length.sub(Factory.length(field)))); } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Sinh.java b/jOOQ/src/main/java/org/jooq/impl/Sinh.java index c22f0693b4..4e71728e56 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Sinh.java +++ b/jOOQ/src/main/java/org/jooq/impl/Sinh.java @@ -35,7 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.exp; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.one; import static org.jooq.impl.Factory.two; @@ -73,7 +72,7 @@ class Sinh extends AbstractFunction { case POSTGRES: case SQLSERVER: case SYBASE: - return exp(argument.mul(two())).sub(one()).div(exp(argument).mul(two())); + return Factory.exp(argument.mul(two())).sub(one()).div(Factory.exp(argument).mul(two())); default: return function("sinh", SQLDataType.NUMERIC, argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Sqrt.java b/jOOQ/src/main/java/org/jooq/impl/Sqrt.java index 41caafcab7..cceb99a3ef 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Sqrt.java +++ b/jOOQ/src/main/java/org/jooq/impl/Sqrt.java @@ -36,7 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.power; import java.math.BigDecimal; @@ -65,7 +64,7 @@ class Sqrt extends AbstractFunction { final Field getFunction0(Configuration configuration) { switch (configuration.getDialect()) { case SQLITE: - return power(argument, 0.5); + return Factory.power(argument, 0.5); default: return function("sqrt", SQLDataType.NUMERIC, argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Tanh.java b/jOOQ/src/main/java/org/jooq/impl/Tanh.java index 63d801bf09..9222923246 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Tanh.java +++ b/jOOQ/src/main/java/org/jooq/impl/Tanh.java @@ -35,7 +35,6 @@ */ package org.jooq.impl; -import static org.jooq.impl.Factory.exp; import static org.jooq.impl.Factory.function; import static org.jooq.impl.Factory.one; import static org.jooq.impl.Factory.two; @@ -73,7 +72,7 @@ class Tanh extends AbstractFunction { case POSTGRES: case SQLSERVER: case SYBASE: - return exp(argument.mul(two())).sub(one()).div(exp(argument.mul(two())).add(one())); + return Factory.exp(argument.mul(two())).sub(one()).div(Factory.exp(argument.mul(two())).add(one())); default: return function("tanh", SQLDataType.NUMERIC, argument); diff --git a/jOOQ/src/main/java/org/jooq/impl/Trim.java b/jOOQ/src/main/java/org/jooq/impl/Trim.java index ce62f33700..1ac4e7ec3d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Trim.java +++ b/jOOQ/src/main/java/org/jooq/impl/Trim.java @@ -36,8 +36,6 @@ package org.jooq.impl; import static org.jooq.impl.Factory.function; -import static org.jooq.impl.Factory.ltrim; -import static org.jooq.impl.Factory.rtrim; import org.jooq.Configuration; import org.jooq.Field; @@ -66,7 +64,7 @@ class Trim extends AbstractFunction { case ASE: case INGRES: case SQLSERVER: - return ltrim(rtrim(argument)); + return Factory.ltrim(Factory.rtrim(argument)); default: return function("trim", SQLDataType.VARCHAR, argument);