[jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] WIDTH_BUCKET
This commit is contained in:
parent
7f90a92b63
commit
69498b8034
@ -15735,7 +15735,7 @@ public class DSL {
|
||||
/**
|
||||
* The <code>RAND</code> function.
|
||||
* <p>
|
||||
* 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 <code>WIDTH_BUCKET</code> function.
|
||||
* <p>
|
||||
* 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 <T extends Number> Field<T> widthBucket(Field<T> field, T low, T high, int buckets) {
|
||||
return new WidthBucket(field, Tools.field(low), Tools.field(high), Tools.field(buckets));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>WIDTH_BUCKET</code> function.
|
||||
* <p>
|
||||
* 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 <T extends Number> Field<T> widthBucket(Field<T> field, Field<T> low, Field<T> high, Field<Integer> 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 <code>WIDTH_BUCKET</code> function which divides a range (low,
|
||||
* high) in buckets of equal size.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static <T extends Number> Field<T> widthBucket(Field<T> field, T low, T high, int buckets) {
|
||||
return widthBucket(field, Tools.field(low, field), Tools.field(high, field), Tools.field(buckets));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the <code>WIDTH_BUCKET</code> function which divides a range (low,
|
||||
* high) in buckets of equal size.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static <T extends Number> Field<T> widthBucket(Field<T> field, Field<T> low, Field<T> high, Field<Integer> buckets) {
|
||||
return new WidthBucket<>(field, low, high, buckets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negate a field to get its negative value.
|
||||
*
|
||||
|
||||
@ -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 <code>WIDTH BUCKET</code> statement.
|
||||
*/
|
||||
final class WidthBucket<T extends Number> extends AbstractField<T> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class WidthBucket<T extends Number>
|
||||
extends
|
||||
AbstractField<T>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -4866100604361006859L;
|
||||
private final Field<T> field;
|
||||
private final Field<T> low;
|
||||
private final Field<T> high;
|
||||
private final Field<Integer> buckets;
|
||||
|
||||
WidthBucket(Field<T> field, Field<T> low, Field<T> high, Field<Integer> buckets) {
|
||||
super(N_WIDTH_BUCKET, field.getDataType());
|
||||
WidthBucket(
|
||||
Field<T> field,
|
||||
Field<T> low,
|
||||
Field<T> high,
|
||||
Field<Integer> 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<T extends Number> extends AbstractField<T> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user