public BucketResolver push(ConstantValue<?> val, boolean inclusive) {
        if (prev == null) {
            prev = val;
        } else if (!(prev instanceof InfiniteValue || val instanceof InfiniteValue)
                   && !prev.getClass().equals(val.getClass())) {
            throw new IllegalArgumentException("Bucket type mismatch, expected '" + prev.getClass().getSimpleName() +
                                               "' got '" + val.getClass().getSimpleName() + "'.");
        } else if (prev instanceof InfiniteValue && val instanceof InfiniteValue) {
            throw new IllegalArgumentException("Bucket type mismatch, cannot both be infinity.");
        }
        if ((++idx % 2) == 0) {
            ConstantValue<?> begin = previnclusive ? prev : nextValue(prev);
            ConstantValue<?> end = inclusive ? nextValue(val) : val;
            if (begin instanceof DoubleValue || end instanceof DoubleValue) {
                buckets.add(new DoubleBucket(begin, end));
            } else if (begin instanceof LongValue || end instanceof LongValue) {
                buckets.add(new LongBucket(begin, end));
            } else if (begin instanceof StringValue || end instanceof StringValue) {
                buckets.add(new StringBucket(begin, end));
            } else if (begin instanceof RawValue || end instanceof RawValue) {
                buckets.add(new RawBucket(begin, end));
            } else {
                throw new UnsupportedOperationException("Bucket type '" + val.getClass() + "' not supported.");
            }
        }
        prev = val;
        previnclusive = inclusive;
        return this;
    }
Pushes the given expression onto this bucket resolver. Once all buckets have been pushed using this method, call
{@link #resolve(GroupingExpression)} to retrieve to combined grouping expression.

@param val the expression to push
@param inclusive whether or not the value is inclusive or not
@throws IllegalArgumentException thrown if the expression is incompatible
container-search/src/main/java/com/yahoo/search/grouping/request/BucketResolver.java