本文整理匯總了Java中com.google.common.collect.Range.atMost方法的典型用法代碼示例。如果您正苦於以下問題:Java Range.atMost方法的具體用法?Java Range.atMost怎麽用?Java Range.atMost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Range
的用法示例。
在下文中一共展示了Range.atMost方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseKillStreak
import com.google.common.collect.Range; //導入方法依賴的package包/類
@MethodParser("kill-streak")
public KillStreakFilter parseKillStreak(Element el) throws InvalidXMLException {
boolean repeat = XMLUtils.parseBoolean(el.getAttribute("repeat"), false);
boolean persistent = XMLUtils.parseBoolean(el.getAttribute("persistent"), false);
Integer count = XMLUtils.parseNumber(el.getAttribute("count"), Integer.class, (Integer) null);
Integer min = XMLUtils.parseNumber(el.getAttribute("min"), Integer.class, (Integer) null);
Integer max = XMLUtils.parseNumber(el.getAttribute("max"), Integer.class, (Integer) null);
Range<Integer> range;
if(count != null) {
range = Range.singleton(count);
} else if(min == null) {
if(max == null) {
throw new InvalidXMLException("kill-streak filter must have a count, min, or max", el);
} else {
range = Range.atMost(max);
}
} else {
if(max == null) {
range = Range.atLeast(min);
} else {
range = Range.closed(min, max);
}
}
if(repeat && !range.hasUpperBound()) {
throw new InvalidXMLException("repeating kill-streak filter must have a count or max", el);
}
return new KillStreakFilter(range, repeat, persistent);
}