本文整理汇总了Java中com.google.common.collect.Range.lowerBoundType方法的典型用法代码示例。如果您正苦于以下问题:Java Range.lowerBoundType方法的具体用法?Java Range.lowerBoundType怎么用?Java Range.lowerBoundType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Range
的用法示例。
在下文中一共展示了Range.lowerBoundType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: describe
import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
* Return an english phrase describing the given {@link Range} e.g.
*
* Range.all() -> "unbounded"
* Range.singleton(3) -> "3"
* Range.atLeast(3) -> "at least 3"
* Range.closedOpen(3, 7) -> "at least 3 and less than 7"
* Range.closed(3, 7) -> "between 3 and 7"
*/
public static String describe(Range<?> range) {
if(range.hasLowerBound() && range.hasUpperBound() && range.lowerBoundType() == BoundType.CLOSED && range.upperBoundType() == BoundType.CLOSED) {
if(range.lowerEndpoint().equals(range.upperEndpoint())) {
// singleton
return range.lowerEndpoint().toString();
} else {
// closed-closed
return "between " + range.lowerEndpoint() + " and " + range.upperEndpoint();
}
}
final List<String> parts = new ArrayList<>(2);
if(range.hasLowerBound()) {
parts.add((range.lowerBoundType() == BoundType.CLOSED ? "at least " : "more than ") + range.lowerEndpoint());
}
if(range.hasUpperBound()) {
parts.add((range.upperBoundType() == BoundType.CLOSED ? "at most " : "less than ") + range.upperEndpoint());
}
switch(parts.size()) {
case 0: return "unbounded";
case 1: return parts.get(0);
default: return parts.get(0) + " and " + parts.get(1);
}
}
示例2: needMinimum
import com.google.common.collect.Range; //导入方法依赖的package包/类
public static int needMinimum(Range<Integer> range) {
assertLowerBound(range);
return range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint()
: range.lowerEndpoint() + 1;
}
示例3: needOpenMinimum
import com.google.common.collect.Range; //导入方法依赖的package包/类
public static int needOpenMinimum(Range<Integer> range) {
assertLowerBound(range);
return range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint() - 1
: range.lowerEndpoint();
}
示例4: toClosed
import com.google.common.collect.Range; //导入方法依赖的package包/类
public static Range<Integer> toClosed(Range<Integer> range) {
assertBounded(range);
return range.lowerBoundType() == BoundType.CLOSED && range.upperBoundType() == BoundType.CLOSED
? range
: Range.closed(needMinimum(range), needMaximum(range));
}