Example usage for com.google.common.collect BoundType CLOSED

List of usage examples for com.google.common.collect BoundType CLOSED

Introduction

In this page you can find the example usage for com.google.common.collect BoundType CLOSED.

Prototype

BoundType CLOSED

To view the source code for com.google.common.collect BoundType CLOSED.

Click Source Link

Document

The endpoint value is considered part of the set ("inclusive").

Usage

From source file:org.apache.pulsar.broker.loadbalance.LoadBalancerTestingUtils.java

public static NamespaceBundle[] makeBundles(final NamespaceBundleFactory nsFactory, final String property,
        final String cluster, final String namespace, final int numBundles) {
    final NamespaceBundle[] result = new NamespaceBundle[numBundles];
    final NamespaceName namespaceName = new NamespaceName(property, cluster, namespace);
    for (int i = 0; i < numBundles - 1; ++i) {
        final long lower = NamespaceBundles.FULL_UPPER_BOUND * i / numBundles;
        final long upper = NamespaceBundles.FULL_UPPER_BOUND * (i + 1) / numBundles;
        result[i] = nsFactory.getBundle(namespaceName,
                Range.range(lower, BoundType.CLOSED, upper, BoundType.OPEN));
    }//from   w  ww  .j a v  a  2  s.co m
    result[numBundles - 1] = nsFactory.getBundle(namespaceName,
            Range.range(NamespaceBundles.FULL_UPPER_BOUND * (numBundles - 1) / numBundles, BoundType.CLOSED,
                    NamespaceBundles.FULL_UPPER_BOUND, BoundType.CLOSED));
    return result;
}

From source file:net.conquiris.lucene.search.SearchSupport.java

static boolean minIncluded(Range<?> range) {
    return range.hasLowerBound() && range.lowerBoundType() == BoundType.CLOSED;
}

From source file:net.conquiris.lucene.search.SearchSupport.java

static boolean maxIncluded(Range<?> range) {
    return range.hasUpperBound() && range.upperBoundType() == BoundType.CLOSED;
}

From source file:com.dangdang.ddframe.rdb.sharding.router.single.SingleRouterUtil.java

/**
 * ??./*from w  w w . ja  v  a  2  s . c om*/
 * 
 * @param condition ?
 * @return 
 */
public static ShardingValue<?> convertConditionToShardingValue(final Condition condition) {
    List<Comparable<?>> conditionValues = condition.getValues();
    switch (condition.getOperator()) {
    case EQUAL:
    case IN:
        if (1 == conditionValues.size()) {
            return new ShardingValue<Comparable<?>>(condition.getColumn().getTableName(),
                    condition.getColumn().getColumnName(), conditionValues.get(0));
        }
        return new ShardingValue<>(condition.getColumn().getTableName(), condition.getColumn().getColumnName(),
                conditionValues);
    case BETWEEN:
        return new ShardingValue<>(condition.getColumn().getTableName(), condition.getColumn().getColumnName(),
                Range.range(conditionValues.get(0), BoundType.CLOSED, conditionValues.get(1),
                        BoundType.CLOSED));
    default:
        throw new UnsupportedOperationException(condition.getOperator().getExpression());
    }
}

From source file:com.google.googlejavaformat.intellij.FormatterUtil.java

private static TextRange toTextRange(Range<Integer> range) {
    checkState(/*from www .  j av  a  2  s . co  m*/
            range.lowerBoundType().equals(BoundType.CLOSED) && range.upperBoundType().equals(BoundType.OPEN));
    return new TextRange(range.lowerEndpoint(), range.upperEndpoint());
}

From source file:io.horizondb.model.core.util.SerializationUtils.java

/**
 * Deserializes a <code>BoundType</code> from the specified reader.
 * /*ww w. j a  va  2  s  .  co m*/
 * @param reader the reader to read from
 * @return the deserialized <code>BoundType</code>
 * @throws IOException if an I/O problem occurs
 */
public static BoundType parseBoundTypeFrom(ByteReader reader) throws IOException {

    byte b = reader.readByte();

    if (b == 0) {
        return BoundType.CLOSED;
    }

    return BoundType.OPEN;
}

From source file:org.dishevelled.bio.align.Alignments.java

/**
 * Confirm that the specified range is [closed, open).
 *
 * @param range range to check, must not be null
 *//*from   w  w  w .  ja  v a  2  s .c om*/
static void checkClosedOpen(final Range<Long> range) {
    checkNotNull(range);
    checkArgument(BoundType.CLOSED == range.lowerBoundType(),
            "range must be [closed, open), lower bound type was open");
    checkArgument(BoundType.OPEN == range.upperBoundType(),
            "range must be [closed, open), upper bound type was closed");
}

From source file:org.apache.lens.cube.parse.CandidateUtil.java

/**
 * Returns true is the Candidates cover the entire time range.
 * @param candidates// w ww.  ja v a2 s  . co  m
 * @param startTime
 * @param endTime
 * @return
 */
static boolean isTimeRangeCovered(Collection<Candidate> candidates, Date startTime, Date endTime) {
    RangeSet<Date> set = TreeRangeSet.create();
    for (Candidate candidate : candidates) {
        set.add(Range.range(candidate.getStartTime(), BoundType.CLOSED, candidate.getEndTime(),
                BoundType.OPEN));
    }
    return set.encloses(Range.range(startTime, BoundType.CLOSED, endTime, BoundType.OPEN));
}

From source file:org.apache.kylin.common.util.RangeUtil.java

public static <C extends Comparable<?>> boolean lowerBoundInclusive(Range<C> range) {
    if (!range.hasLowerBound()) {
        throw new IllegalArgumentException(("This range does not have lower bound" + range));
    }/*from ww w. j a  va2  s .  co  m*/
    return range.lowerBoundType() == BoundType.CLOSED;
}

From source file:org.apache.druid.sql.calcite.filtration.Bounds.java

public static Range<BoundValue> toRange(final BoundDimFilter bound) {
    final BoundValue upper = bound.getUpper() != null ? new BoundValue(bound.getUpper(), bound.getOrdering())
            : null;//from w  w  w  .ja va  2s.com
    final BoundValue lower = bound.getLower() != null ? new BoundValue(bound.getLower(), bound.getOrdering())
            : null;

    if (lower == null) {
        return bound.isUpperStrict() ? Range.lessThan(upper) : Range.atMost(upper);
    } else if (upper == null) {
        return bound.isLowerStrict() ? Range.greaterThan(lower) : Range.atLeast(lower);
    } else {
        return Range.range(lower, bound.isLowerStrict() ? BoundType.OPEN : BoundType.CLOSED, upper,
                bound.isUpperStrict() ? BoundType.OPEN : BoundType.CLOSED);
    }
}