本文整理汇总了Java中com.google.common.collect.Range.all方法的典型用法代码示例。如果您正苦于以下问题:Java Range.all方法的具体用法?Java Range.all怎么用?Java Range.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Range
的用法示例。
在下文中一共展示了Range.all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toRange
import com.google.common.collect.Range; //导入方法依赖的package包/类
public static Range toRange(Coprocessor.KeyRange range) {
if (range == null || (range.getStart().isEmpty() && range.getEnd().isEmpty())) {
return Range.all();
}
if (range.getStart().isEmpty()) {
return Range.lessThan(Comparables.wrap(range.getEnd()));
}
if (range.getEnd().isEmpty()) {
return Range.atLeast(Comparables.wrap(range.getStart()));
}
return Range.closedOpen(Comparables.wrap(range.getStart()), Comparables.wrap(range.getEnd()));
}
示例2: makeRange
import com.google.common.collect.Range; //导入方法依赖的package包/类
public static Range makeRange(ByteString startKey, ByteString endKey) {
if (startKey.isEmpty() && endKey.isEmpty()) {
return Range.all();
}
if (startKey.isEmpty()) {
return Range.lessThan(Comparables.wrap(endKey));
} else if (endKey.isEmpty()) {
return Range.atLeast(Comparables.wrap(startKey));
}
return Range.closedOpen(Comparables.wrap(startKey), Comparables.wrap(endKey));
}
示例3: generateRange
import com.google.common.collect.Range; //导入方法依赖的package包/类
@Empty private static <C extends Comparable<?>> Range<C> generateRange() {
return Range.all();
}
示例4: parseNumericRange
import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
* Parse a range in the standard mathematical format e.g.
*
* [0, 1) for a closed-open range from 0 to 1.
*
* Can also parse single numbers as a closed range e.g.
*
* 5 for a closed-closed range from 5 to 5.
*/
public static <T extends Number & Comparable<T>> Range<T> parseNumericRange(Node node, Class<T> type) throws InvalidXMLException {
String value = node.getValue();
Matcher matcher = RANGE_RE.matcher(value);
if(!matcher.matches()) {
T number = parseNumber(node, value, type, (T) null);
if(number != null) {
return Range.singleton(number);
}
throw new InvalidXMLException("Invalid " + type.getSimpleName().toLowerCase() + " range '" + value + "'", node);
}
T lower = parseNumber(node, matcher.group(2), type, true);
T upper = parseNumber(node, matcher.group(3), type, true);
BoundType lowerType = null, upperType = null;
if(!Double.isInfinite(lower.doubleValue())) {
lowerType = "(".equals(matcher.group(1)) ? BoundType.OPEN : BoundType.CLOSED;
}
if(!Double.isInfinite(upper.doubleValue())) {
upperType = ")".equals(matcher.group(4)) ? BoundType.OPEN : BoundType.CLOSED;
}
if(lower.compareTo(upper) == 1) {
throw new InvalidXMLException("range lower bound (" + lower + ") cannot be greater than upper bound (" + upper + ")", node);
}
if(lowerType == null) {
if(upperType == null) {
return Range.all();
} else {
return Range.upTo(upper, upperType);
}
} else {
if(upperType == null) {
return Range.downTo(lower, lowerType);
} else {
return Range.range(lower, lowerType, upper, upperType);
}
}
}
示例5: RangeOption
import com.google.common.collect.Range; //导入方法依赖的package包/类
RangeOption(T defaultValue, String describe) {
super(defaultValue, describe);
range = Range.all();
}