[jOOQ/jOOQ#12425] Move POWER (the operator) to API generator

This includes:
- [jOOQ/jOOQ#12431] Extract arithmetic operations into their own classes
This commit is contained in:
Lukas Eder 2021-09-15 12:14:37 +02:00
parent 6fbbd2e3e0
commit 88c6652b38
2 changed files with 55 additions and 44 deletions

View File

@ -47,6 +47,7 @@ package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
// ...
import static org.jooq.SQLDialect.FIREBIRD;
// ...
import static org.jooq.SQLDialect.H2;
@ -826,6 +827,38 @@ extends
@Support
Field<T> rem(Field<? extends Number> arg2);
/**
* The <code>POWER</code> operator.
*
* @param exponent is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> power(Number exponent);
/**
* The <code>POWER</code> operator.
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> power(Field<? extends Number> exponent);
/**
* The <code>POW</code> operator, an alias for the <code>POWER</code> operator.
*
* @param exponent is wrapped as {@link #val(Object)}.
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> pow(Number exponent);
/**
* The <code>POW</code> operator, an alias for the <code>POWER</code> operator.
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> pow(Field<? extends Number> exponent);
/**
* The <code>SHL</code> operator.
* <p>
@ -1168,50 +1201,6 @@ extends
@Support
Field<T> divide(Field<? extends Number> value);
/**
* An arithmetic expression getting this value raised to the power of <code>exponent</code>.
* <p>
* This renders the power operation where available:
* <code><pre>[this] ^ [value]</pre></code> ... or the power function
* elsewhere: <code><pre>power([this], [value])</pre></code>
*
* @see DSL#power(Field, Number)
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> pow(Number exponent);
/**
* An arithmetic expression getting this value raised to the power of <code>exponent</code>.
* <p>
* This renders the power operation where available:
* <code><pre>[this] ^ [value]</pre></code> ... or the power function
* elsewhere: <code><pre>power([this], [value])</pre></code>
*
* @see DSL#power(Field, Field)
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> pow(Field<? extends Number> exponent);
/**
* An alias for {@link #power(Number)}.
*
* @see #power(Number)
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> power(Number exponent);
/**
* An alias for {@link #power(Field)}.
*
* @see #power(Field)
*/
@NotNull
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTE })
Field<BigDecimal> power(Field<? extends Number> exponent);
// ------------------------------------------------------------------------
// XML predicates
// ------------------------------------------------------------------------

View File

@ -447,6 +447,28 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
return mod(arg2);
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final Field<BigDecimal> power(Number exponent) {
return DSL.power((Field) this, exponent);
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final Field<BigDecimal> power(Field<? extends Number> exponent) {
return DSL.power((Field) this, exponent);
}
@Override
public final Field<BigDecimal> pow(Number exponent) {
return power(exponent);
}
@Override
public final Field<BigDecimal> pow(Field<? extends Number> exponent) {
return power(exponent);
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public final Field<T> shl(Number count) {