本文整理了Java中com.google.common.collect.Range.lowerBoundType
方法的一些代码示例,展示了Range.lowerBoundType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.lowerBoundType
方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:lowerBoundType
[英]Returns the type of this range's lower bound: BoundType#CLOSED if the range includes its lower endpoint, BoundType#OPEN if it does not.
[中]返回此范围下限的类型:如果范围包含其下限,则返回BoundType#CLOSED;如果范围不包含其下限,则返回BoundType#OPEN。
代码示例来源:origin: apache/kylin
public static <C extends Comparable<?>> boolean lowerBoundInclusive(Range<C> range) {
if (!range.hasLowerBound()) {
throw new IllegalArgumentException(("This range does not have lower bound" + range));
}
return range.lowerBoundType() == BoundType.CLOSED;
}
代码示例来源:origin: google/guava
.tailMap(
lowerBoundWindow.lowerBound.endpoint(),
lowerBoundWindow.lowerBoundType() == BoundType.CLOSED)
.values()
.iterator();
代码示例来源:origin: google/google-java-format
private static TextRange toTextRange(Range<Integer> range) {
checkState(
range.lowerBoundType().equals(BoundType.CLOSED)
&& range.upperBoundType().equals(BoundType.OPEN));
return new TextRange(range.lowerEndpoint(), range.upperEndpoint());
}
}
代码示例来源:origin: apache/incubator-druid
private static Range<Long> toLongRange(final Range<BoundValue> range)
{
if (!range.hasUpperBound() && !range.hasLowerBound()) {
return Range.all();
} else if (range.hasUpperBound() && !range.hasLowerBound()) {
return Range.upTo(Long.parseLong(range.upperEndpoint().getValue()), range.upperBoundType());
} else if (!range.hasUpperBound() && range.hasLowerBound()) {
return Range.downTo(Long.parseLong(range.lowerEndpoint().getValue()), range.lowerBoundType());
} else {
return Range.range(
Long.parseLong(range.lowerEndpoint().getValue()), range.lowerBoundType(),
Long.parseLong(range.upperEndpoint().getValue()), range.upperBoundType()
);
}
}
}
代码示例来源:origin: google/guava
return map.subMap(
range.lowerEndpoint(),
range.lowerBoundType() == BoundType.CLOSED,
range.upperEndpoint(),
range.upperBoundType() == BoundType.CLOSED);
} else if (range.hasLowerBound()) {
return map.tailMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
} else if (range.hasUpperBound()) {
return map.headMap(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED);
代码示例来源:origin: google/guava
return set.subSet(
range.lowerEndpoint(),
range.lowerBoundType() == BoundType.CLOSED,
range.upperEndpoint(),
range.upperBoundType() == BoundType.CLOSED);
} else if (range.hasLowerBound()) {
return set.tailSet(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
} else if (range.hasUpperBound()) {
return set.headSet(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED);
代码示例来源:origin: google/guava
/** Converts a Range to a GeneralRange. */
static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
@Nullable T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;
@Nullable T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null;
BoundType upperBoundType = range.hasUpperBound() ? range.upperBoundType() : OPEN;
return new GeneralRange<T>(
Ordering.natural(),
range.hasLowerBound(),
lowerEndpoint,
lowerBoundType,
range.hasUpperBound(),
upperEndpoint,
upperBoundType);
}
代码示例来源:origin: google/guava
private static void assertUnboundedBelow(Range<Integer> range) {
assertFalse(range.hasLowerBound());
try {
range.lowerEndpoint();
fail();
} catch (IllegalStateException expected) {
}
try {
range.lowerBoundType();
fail();
} catch (IllegalStateException expected) {
}
}
代码示例来源:origin: google/j2objc
/** Converts a Range to a GeneralRange. */
static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
@NullableDecl T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;
@NullableDecl T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null;
BoundType upperBoundType = range.hasUpperBound() ? range.upperBoundType() : OPEN;
return new GeneralRange<T>(
Ordering.natural(),
range.hasLowerBound(),
lowerEndpoint,
lowerBoundType,
range.hasUpperBound(),
upperEndpoint,
upperBoundType);
}
代码示例来源:origin: google/guava
public void testGreaterThan() {
Range<Integer> range = Range.greaterThan(5);
assertFalse(range.contains(5));
assertTrue(range.contains(6));
assertTrue(range.contains(Integer.MAX_VALUE));
assertTrue(range.hasLowerBound());
assertEquals(5, (int) range.lowerEndpoint());
assertEquals(OPEN, range.lowerBoundType());
assertUnboundedAbove(range);
assertFalse(range.isEmpty());
assertEquals("(5..+\u221e)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testAtLeast() {
Range<Integer> range = Range.atLeast(6);
assertFalse(range.contains(5));
assertTrue(range.contains(6));
assertTrue(range.contains(Integer.MAX_VALUE));
assertTrue(range.hasLowerBound());
assertEquals(6, (int) range.lowerEndpoint());
assertEquals(CLOSED, range.lowerBoundType());
assertUnboundedAbove(range);
assertFalse(range.isEmpty());
assertEquals("[6..+\u221e)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public static void serialize(SerializationStreamWriter writer, Range<?> instance)
throws SerializationException {
if (instance.hasLowerBound()) {
writer.writeBoolean(true);
writer.writeBoolean(instance.lowerBoundType() == BoundType.CLOSED);
writer.writeObject(instance.lowerEndpoint());
} else {
writer.writeBoolean(false);
}
if (instance.hasUpperBound()) {
writer.writeBoolean(true);
writer.writeBoolean(instance.upperBoundType() == BoundType.CLOSED);
writer.writeObject(instance.upperEndpoint());
} else {
writer.writeBoolean(false);
}
}
}
代码示例来源:origin: google/guava
public void testSingleton() {
Range<Integer> range = Range.closed(4, 4);
assertFalse(range.contains(3));
assertTrue(range.contains(4));
assertFalse(range.contains(5));
assertTrue(range.hasLowerBound());
assertEquals(4, (int) range.lowerEndpoint());
assertEquals(CLOSED, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(4, (int) range.upperEndpoint());
assertEquals(CLOSED, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("[4..4]", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: apache/incubator-druid
public static BoundDimFilter toFilter(final BoundRefKey boundRefKey, final Range<BoundValue> range)
{
return new BoundDimFilter(
boundRefKey.getDimension(),
range.hasLowerBound() ? range.lowerEndpoint().getValue() : null,
range.hasUpperBound() ? range.upperEndpoint().getValue() : null,
range.hasLowerBound() && range.lowerBoundType() == BoundType.OPEN,
range.hasUpperBound() && range.upperBoundType() == BoundType.OPEN,
null,
boundRefKey.getExtractionFn(),
boundRefKey.getComparator()
);
}
代码示例来源:origin: google/guava
public void testEmpty2() {
Range<Integer> range = Range.openClosed(4, 4);
assertFalse(range.contains(3));
assertFalse(range.contains(4));
assertFalse(range.contains(5));
assertTrue(range.hasLowerBound());
assertEquals(4, (int) range.lowerEndpoint());
assertEquals(OPEN, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(4, (int) range.upperEndpoint());
assertEquals(CLOSED, range.upperBoundType());
assertTrue(range.isEmpty());
assertEquals("(4..4]", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testEmpty1() {
Range<Integer> range = Range.closedOpen(4, 4);
assertFalse(range.contains(3));
assertFalse(range.contains(4));
assertFalse(range.contains(5));
assertTrue(range.hasLowerBound());
assertEquals(4, (int) range.lowerEndpoint());
assertEquals(CLOSED, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(4, (int) range.upperEndpoint());
assertEquals(OPEN, range.upperBoundType());
assertTrue(range.isEmpty());
assertEquals("[4..4)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testClosed() {
Range<Integer> range = Range.closed(5, 7);
checkContains(range);
assertTrue(range.hasLowerBound());
assertEquals(5, (int) range.lowerEndpoint());
assertEquals(CLOSED, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(7, (int) range.upperEndpoint());
assertEquals(CLOSED, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("[5..7]", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testOpen() {
Range<Integer> range = Range.open(4, 8);
checkContains(range);
assertTrue(range.hasLowerBound());
assertEquals(4, (int) range.lowerEndpoint());
assertEquals(OPEN, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(8, (int) range.upperEndpoint());
assertEquals(OPEN, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("(4..8)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testClosedOpen() {
Range<Integer> range = Range.closedOpen(5, 8);
checkContains(range);
assertTrue(range.hasLowerBound());
assertEquals(5, (int) range.lowerEndpoint());
assertEquals(CLOSED, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(8, (int) range.upperEndpoint());
assertEquals(OPEN, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("[5..8)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testOpenClosed() {
Range<Integer> range = Range.openClosed(4, 7);
checkContains(range);
assertTrue(range.hasLowerBound());
assertEquals(4, (int) range.lowerEndpoint());
assertEquals(OPEN, range.lowerBoundType());
assertTrue(range.hasUpperBound());
assertEquals(7, (int) range.upperEndpoint());
assertEquals(CLOSED, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("(4..7]", range.toString());
reserializeAndAssert(range);
}
内容来源于网络,如有侵权,请联系作者删除!