diff --git a/jOOQ/src/main/java/org/jooq/impl/Add.java b/jOOQ/src/main/java/org/jooq/impl/Add.java new file mode 100644 index 0000000000..c0fa8b506a --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Add.java @@ -0,0 +1,176 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The ADD statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Add +extends + AbstractTransformable +implements + QOM.Add +{ + + final Field arg1; + final Field arg2; + + Add( + Field arg1, + Field arg2 + ) { + super( + N_ADD, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept0(Context ctx) { + + + + + + + + ctx.sql('('); + Expression., Add>acceptAssociative( + ctx, + this, + q -> new Expression.Expr<>(q.arg1, Operators.OP_PLUS, q.arg2), + c -> c.sql(' ') + ); + ctx.sql(')'); + } + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.ADD, arg2, false, transform); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Add $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Add $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Add> constructor() { + return (a1, a2) -> new Add<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof Add) { Add o = (Add) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/Div.java b/jOOQ/src/main/java/org/jooq/impl/Div.java new file mode 100644 index 0000000000..af82cd55ea --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Div.java @@ -0,0 +1,169 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The DIV statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Div +extends + AbstractTransformable +implements + QOM.Div +{ + + final Field arg1; + final Field arg2; + + Div( + Field arg1, + Field arg2 + ) { + super( + N_DIV, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept0(Context ctx) { + + + + + + + + ctx.sql('(').visit(arg1).sql(" / ").visit(arg2).sql(')'); + } + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.DIVIDE, arg2, false, transform); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Div $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Div $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Div> constructor() { + return (a1, a2) -> new Div<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof Div) { Div o = (Div) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/IAdd.java b/jOOQ/src/main/java/org/jooq/impl/IAdd.java new file mode 100644 index 0000000000..3bf8af9fe4 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/IAdd.java @@ -0,0 +1,153 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The ADD statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class IAdd +extends + AbstractTransformable +implements + QOM.Add +{ + + final Field arg1; + final Field arg2; + + IAdd( + Field arg1, + Field arg2 + ) { + super( + N_ADD, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + public final void accept0(Context ctx) { + ctx.visit(transform(Add::new)); + } + + + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.ADD, arg2, true, transform); + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Add $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Add $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Add> constructor() { + return (a1, a2) -> new IAdd<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof IAdd) { IAdd o = (IAdd) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/IDiv.java b/jOOQ/src/main/java/org/jooq/impl/IDiv.java new file mode 100644 index 0000000000..d7fab246c8 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/IDiv.java @@ -0,0 +1,153 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The DIV statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class IDiv +extends + AbstractTransformable +implements + QOM.Div +{ + + final Field arg1; + final Field arg2; + + IDiv( + Field arg1, + Field arg2 + ) { + super( + N_DIV, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + public final void accept0(Context ctx) { + ctx.visit(transform(Div::new)); + } + + + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.DIVIDE, arg2, true, transform); + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Div $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Div $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Div> constructor() { + return (a1, a2) -> new IDiv<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof IDiv) { IDiv o = (IDiv) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/IMul.java b/jOOQ/src/main/java/org/jooq/impl/IMul.java new file mode 100644 index 0000000000..d841e15a56 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/IMul.java @@ -0,0 +1,153 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The MUL statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class IMul +extends + AbstractTransformable +implements + QOM.Mul +{ + + final Field arg1; + final Field arg2; + + IMul( + Field arg1, + Field arg2 + ) { + super( + N_MUL, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + public final void accept0(Context ctx) { + ctx.visit(transform(Mul::new)); + } + + + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.MULTIPLY, arg2, true, transform); + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Mul $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Mul $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Mul> constructor() { + return (a1, a2) -> new IMul<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof IMul) { IMul o = (IMul) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/ISub.java b/jOOQ/src/main/java/org/jooq/impl/ISub.java new file mode 100644 index 0000000000..3c49dd5aa9 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/ISub.java @@ -0,0 +1,153 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The SUB statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class ISub +extends + AbstractTransformable +implements + QOM.Sub +{ + + final Field arg1; + final Field arg2; + + ISub( + Field arg1, + Field arg2 + ) { + super( + N_SUB, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + public final void accept0(Context ctx) { + ctx.visit(transform(Sub::new)); + } + + + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.SUBTRACT, arg2, true, transform); + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Sub $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Sub $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Sub> constructor() { + return (a1, a2) -> new ISub<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof ISub) { ISub o = (ISub) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/Mul.java b/jOOQ/src/main/java/org/jooq/impl/Mul.java new file mode 100644 index 0000000000..77e882bbd4 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Mul.java @@ -0,0 +1,177 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.Add; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The MUL statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Mul +extends + AbstractTransformable +implements + QOM.Mul +{ + + final Field arg1; + final Field arg2; + + Mul( + Field arg1, + Field arg2 + ) { + super( + N_MUL, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept0(Context ctx) { + + + + + + + + ctx.sql('('); + Expression., Mul>acceptAssociative( + ctx, + this, + q -> new Expression.Expr<>(q.arg1, Operators.OP_AST, q.arg2), + c -> c.sql(' ') + ); + ctx.sql(')'); + } + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.MULTIPLY, arg2, false, transform); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Mul $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Mul $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Mul> constructor() { + return (a1, a2) -> new Mul<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof Mul) { Mul o = (Mul) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/Sub.java b/jOOQ/src/main/java/org/jooq/impl/Sub.java new file mode 100644 index 0000000000..00453fc18a --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Sub.java @@ -0,0 +1,169 @@ +/* + * 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.impl.Tools.DataExtendedKey.*; +import static org.jooq.impl.Tools.DataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The SUB statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Sub +extends + AbstractTransformable +implements + QOM.Sub +{ + + final Field arg1; + final Field arg2; + + Sub( + Field arg1, + Field arg2 + ) { + super( + N_SUB, + allNotNull((DataType) dataType(arg1), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept0(Context ctx) { + + + + + + + + ctx.sql('(').visit(arg1).sql(" - ").visit(arg2).sql(')'); + } + + @Override + public final Field transform(TransformUnneededArithmeticExpressions transform) { + return Expression.transform(this, arg1, ExpressionOperator.SUBTRACT, arg2, false, transform); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.Sub $arg1(Field newValue) { + return constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Sub $arg2(Field newValue) { + return constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Sub> constructor() { + return (a1, a2) -> new Sub<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof Sub) { Sub o = (Sub) that; + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +}