本文整理了Java中com.google.common.collect.Range.hasLowerBound
方法的一些代码示例,展示了Range.hasLowerBound
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.hasLowerBound
方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:hasLowerBound
[英]Returns true if this range has a lower endpoint.
[中]如果此范围的端点较低,则返回true。
代码示例来源: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
if (!upperBoundWindow.hasLowerBound()) {
backingItr = rangesByLowerBound.values().iterator();
} else {
代码示例来源: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
if (!span.hasLowerBound()) {
代码示例来源: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
if (map.comparator() != null
&& map.comparator() != Ordering.natural()
&& range.hasLowerBound()
&& range.hasUpperBound()) {
checkArgument(
"map is using a custom comparator which is inconsistent with the natural ordering.");
if (range.hasLowerBound() && range.hasUpperBound()) {
return map.subMap(
range.lowerEndpoint(),
range.upperEndpoint(),
range.upperBoundType() == BoundType.CLOSED);
} else if (range.hasLowerBound()) {
return map.tailMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
} else if (range.hasUpperBound()) {
代码示例来源:origin: google/guava
if (set.comparator() != null
&& set.comparator() != Ordering.natural()
&& range.hasLowerBound()
&& range.hasUpperBound()) {
checkArgument(
"set is using a custom comparator which is inconsistent with the natural ordering.");
if (range.hasLowerBound() && range.hasUpperBound()) {
return set.subSet(
range.lowerEndpoint(),
range.upperEndpoint(),
range.upperBoundType() == BoundType.CLOSED);
} else if (range.hasLowerBound()) {
return set.tailSet(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
} else if (range.hasUpperBound()) {
代码示例来源: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
Range<C> effectiveRange = range;
try {
if (!range.hasLowerBound()) {
effectiveRange = effectiveRange.intersection(Range.atLeast(domain.minValue()));
代码示例来源: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/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: 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 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);
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!