diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index fbef7b0df9..e64fc680a0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -15735,7 +15735,7 @@ public class DSL { /** * The RAND function. *

- * Turn a value in degrees to radians. + * Get a random numeric value. */ @NotNull @Support @@ -16740,6 +16740,38 @@ public class DSL { return new Upper(string); } + /** + * The WIDTH_BUCKET function. + *

+ * Divide a range into buckets of equal size. + * + * @param field The value to divide into the range. + * @param low The lower bound of the range. + * @param high The upper bound of the range. + * @param buckets The number of buckets to produce. + */ + @NotNull + @Support + public static Field widthBucket(Field field, T low, T high, int buckets) { + return new WidthBucket(field, Tools.field(low), Tools.field(high), Tools.field(buckets)); + } + + /** + * The WIDTH_BUCKET function. + *

+ * Divide a range into buckets of equal size. + * + * @param field The value to divide into the range. + * @param low The lower bound of the range. + * @param high The upper bound of the range. + * @param buckets The number of buckets to produce. + */ + @NotNull + @Support + public static Field widthBucket(Field field, Field low, Field high, Field buckets) { + return new WidthBucket(field, low, high, buckets); + } + /** @@ -20065,26 +20097,6 @@ public class DSL { return new Least<>(Tools.nullSafeDataType(field), Tools.nullSafe(combine(field, others))); } - /** - * Get the WIDTH_BUCKET function which divides a range (low, - * high) in buckets of equal size. - */ - @NotNull - @Support - public static Field widthBucket(Field field, T low, T high, int buckets) { - return widthBucket(field, Tools.field(low, field), Tools.field(high, field), Tools.field(buckets)); - } - - /** - * Get the WIDTH_BUCKET function which divides a range (low, - * high) in buckets of equal size. - */ - @NotNull - @Support - public static Field widthBucket(Field field, Field low, Field high, Field buckets) { - return new WidthBucket<>(field, low, high, buckets); - } - /** * Negate a field to get its negative value. * diff --git a/jOOQ/src/main/java/org/jooq/impl/WidthBucket.java b/jOOQ/src/main/java/org/jooq/impl/WidthBucket.java index 9b92f16c2c..bb1d3e727f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/WidthBucket.java +++ b/jOOQ/src/main/java/org/jooq/impl/WidthBucket.java @@ -37,41 +37,58 @@ */ package org.jooq.impl; -import static org.jooq.impl.DSL.keyword; -import static org.jooq.impl.DSL.one; -import static org.jooq.impl.DSL.zero; -import static org.jooq.impl.Internal.iadd; -import static org.jooq.impl.Internal.idiv; -import static org.jooq.impl.Internal.imul; -import static org.jooq.impl.Internal.isub; -import static org.jooq.impl.Names.N_WIDTH_BUCKET; +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.impl.*; +import org.jooq.tools.*; + +import java.util.*; -import org.jooq.Context; -import org.jooq.Field; /** - * @author Lukas Eder + * The WIDTH BUCKET statement. */ -final class WidthBucket extends AbstractField { +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class WidthBucket +extends + AbstractField +{ + + private static final long serialVersionUID = 1L; - /** - * Generated UID - */ - private static final long serialVersionUID = -4866100604361006859L; private final Field field; private final Field low; private final Field high; private final Field buckets; - WidthBucket(Field field, Field low, Field high, Field buckets) { - super(N_WIDTH_BUCKET, field.getDataType()); + WidthBucket( + Field field, + Field low, + Field high, + Field buckets + ) { + super(N_WIDTH_BUCKET, allNotNull((DataType) dataType(INTEGER, field, false), field, low, high, buckets)); - this.field = field; - this.low = low; - this.high = high; - this.buckets = buckets; + this.field = nullSafeNotNull(field, INTEGER); + this.low = nullSafeNotNull(low, INTEGER); + this.high = nullSafeNotNull(high, INTEGER); + this.buckets = nullSafeNotNull(buckets, INTEGER); } + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + @SuppressWarnings({ "unchecked" }) @Override public void accept(Context ctx) { @@ -105,4 +122,23 @@ final class WidthBucket extends AbstractField { } } + + + // ------------------------------------------------------------------------- + // The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof WidthBucket) { + return + StringUtils.equals(field, ((WidthBucket) that).field) && + StringUtils.equals(low, ((WidthBucket) that).low) && + StringUtils.equals(high, ((WidthBucket) that).high) && + StringUtils.equals(buckets, ((WidthBucket) that).buckets) + ; + } + else + return super.equals(that); + } }