本文整理了Java中com.google.common.collect.Range.toString
方法的一些代码示例,展示了Range.toString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.toString
方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:toString
[英]Returns a string representation of this range, such as "[3..5)" (other examples are listed in the class documentation).
[中]
代码示例来源:origin: google/guava
/**
* Returns a string representation of this range, such as {@code "[3..5)"} (other examples are
* listed in the class documentation).
*/
@Override
public String toString() {
return toString(lowerBound, upperBound);
}
代码示例来源:origin: google/j2objc
/**
* Returns a string representation of this range, such as {@code "[3..5)"} (other examples are
* listed in the class documentation).
*/
@Override
public String toString() {
return toString(lowerBound, upperBound);
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns a string representation of this range, such as {@code "[3..5)"} (other examples are
* listed in the class documentation).
*/
@Override
public String toString() {
return toString(lowerBound, upperBound);
}
代码示例来源:origin: google/guava
/** Returns a short-hand representation of the contents such as {@code "[1..100]"}. */
@Override
public String toString() {
return range().toString();
}
代码示例来源:origin: google/guava
private Range(Cut<C> lowerBound, Cut<C> upperBound) {
this.lowerBound = checkNotNull(lowerBound);
this.upperBound = checkNotNull(upperBound);
if (lowerBound.compareTo(upperBound) > 0
|| lowerBound == Cut.<C>aboveAll()
|| upperBound == Cut.<C>belowAll()) {
throw new IllegalArgumentException("Invalid range: " + toString(lowerBound, upperBound));
}
}
代码示例来源:origin: google/j2objc
/** Returns a short-hand representation of the contents such as {@code "[1..100]"}. */
@Override
public String toString() {
return range().toString();
}
代码示例来源:origin: google/j2objc
private Range(Cut<C> lowerBound, Cut<C> upperBound) {
this.lowerBound = checkNotNull(lowerBound);
this.upperBound = checkNotNull(upperBound);
if (lowerBound.compareTo(upperBound) > 0
|| lowerBound == Cut.<C>aboveAll()
|| upperBound == Cut.<C>belowAll()) {
throw new IllegalArgumentException("Invalid range: " + toString(lowerBound, upperBound));
}
}
代码示例来源:origin: wildfly/wildfly
private Range(Cut<C> lowerBound, Cut<C> upperBound) {
this.lowerBound = checkNotNull(lowerBound);
this.upperBound = checkNotNull(upperBound);
if (lowerBound.compareTo(upperBound) > 0
|| lowerBound == Cut.<C>aboveAll()
|| upperBound == Cut.<C>belowAll()) {
throw new IllegalArgumentException("Invalid range: " + toString(lowerBound, upperBound));
}
}
代码示例来源:origin: google/guava
public void testAll() {
Range<Integer> range = Range.all();
assertTrue(range.contains(Integer.MIN_VALUE));
assertTrue(range.contains(Integer.MAX_VALUE));
assertUnboundedBelow(range);
assertUnboundedAbove(range);
assertFalse(range.isEmpty());
assertEquals("(-\u221e..+\u221e)", range.toString());
assertSame(range, reserializeAndAssert(range));
assertSame(range, Range.all());
}
代码示例来源:origin: google/guava
public void testLessThan() {
Range<Integer> range = Range.lessThan(5);
assertTrue(range.contains(Integer.MIN_VALUE));
assertTrue(range.contains(4));
assertFalse(range.contains(5));
assertUnboundedBelow(range);
assertTrue(range.hasUpperBound());
assertEquals(5, (int) range.upperEndpoint());
assertEquals(OPEN, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("(-\u221e..5)", range.toString());
reserializeAndAssert(range);
}
代码示例来源: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 void testAtMost() {
Range<Integer> range = Range.atMost(4);
assertTrue(range.contains(Integer.MIN_VALUE));
assertTrue(range.contains(4));
assertFalse(range.contains(5));
assertUnboundedBelow(range);
assertTrue(range.hasUpperBound());
assertEquals(4, (int) range.upperEndpoint());
assertEquals(CLOSED, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("(-\u221e..4]", range.toString());
reserializeAndAssert(range);
}
代码示例来源: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 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 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 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);
}
内容来源于网络,如有侵权,请联系作者删除!