当前位置: 首页>>代码示例>>Java>>正文


Java Range.contains方法代码示例

本文整理汇总了Java中com.google.common.collect.Range.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Range.contains方法的具体用法?Java Range.contains怎么用?Java Range.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Range的用法示例。


在下文中一共展示了Range.contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseChildList

import com.google.common.collect.Range; //导入方法依赖的package包/类
public List<T> parseChildList(Element parent, Range<Integer> count) throws InvalidXMLException {
    final List<T> list = parseChildren(parent).collect(Collectors.toList());
    if(count.contains(list.size())) return list;

    final Optional<Integer> min = Ranges.minimum(count), max = Ranges.maximum(count);

    if(!max.isPresent()) {
        throw new InvalidXMLException("Expected " + min.get() + " or more child elements", parent);
    } else if(!min.isPresent()) {
        throw new InvalidXMLException("Expected no more than " + max.get() + " child elements", parent);
    } else if(min.equals(max)) {
        throw new InvalidXMLException("Expected exactly " + min.get() + " child elements", parent);
    } else {
        throw new InvalidXMLException("Expected between " + min.get() + " and " + max.get() + " child elements", parent);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:FeatureParser.java

示例2: parseNumber

import com.google.common.collect.Range; //导入方法依赖的package包/类
public static <T extends Number & Comparable<T>> T parseNumber(Node node, String text, Class<T> type, Range<T> range) throws InvalidXMLException {
    T value = parseNumber(node, text, type, true);
    if(!range.contains(value)) {
        throw new InvalidXMLException(value + " is not in the range " + range, node);
    }
    return value;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:XMLUtils.java

示例3: parseRandom

import com.google.common.collect.Range; //导入方法依赖的package包/类
@MethodParser("random")
public Filter parseRandom(Element el) throws InvalidXMLException {
    Node node = new Node(el);
    Range<Double> chance;
    try {
        chance = Range.closedOpen(0d, XMLUtils.parseNumber(node, Double.class));
    } catch(InvalidXMLException e) {
        chance = XMLUtils.parseNumericRange(node, Double.class);
    }

    Range<Double> valid = Range.closed(0d, 1d);
    if (valid.encloses(chance)) {
        return proto.isNoOlderThan(ProtoVersions.EVENT_QUERIES) ? new RandomFilter(chance)
                                                                : new LegacyRandomFilter(chance);
    } else {
        double lower = chance.hasLowerBound() ? chance.lowerEndpoint() : Double.NEGATIVE_INFINITY;
        double upper = chance.hasUpperBound() ? chance.upperEndpoint() : Double.POSITIVE_INFINITY;
        double invalid;
        if(!valid.contains(lower)) {
            invalid = lower;
        } else {
            invalid = upper;
        }

        throw new InvalidXMLException("chance value (" + invalid + ") is not between 0 and 1", el);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:28,代码来源:FilterDefinitionParser.java

示例4: batchGet

import com.google.common.collect.Range; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<KvPair> batchGet(List<ByteString> keys) {
  TiRegion curRegion = null;
  Range curKeyRange = null;
  Pair<TiRegion, Store> lastPair;
  List<ByteString> keyBuffer = new ArrayList<>();
  List<KvPair> result = new ArrayList<>(keys.size());
  for (ByteString key : keys) {
    if (curRegion == null || !curKeyRange.contains(Comparables.wrap(key))) {
      Pair<TiRegion, Store> pair = session.getRegionManager().getRegionStorePairByKey(key);
      lastPair = pair;
      curRegion = pair.first;
      curKeyRange = makeRange(curRegion.getStartKey(), curRegion.getEndKey());

      try (RegionStoreClient client =
               RegionStoreClient.create(lastPair.first, lastPair.second, getSession())) {
        List<KvPair> partialResult = client.batchGet(keyBuffer, timestamp.getVersion());
        // TODO: Add lock check
        result.addAll(partialResult);
      } catch (Exception e) {
        throw new TiClientInternalException("Error Closing Store client.", e);
      }
      keyBuffer = new ArrayList<>();
      keyBuffer.add(key);
    }
  }
  return result;
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:29,代码来源:Snapshot.java

示例5: base62ToDecimal

import com.google.common.collect.Range; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Long base62ToDecimal(String base62) {
	int base62Length = base62.length();
	if (base62Length > BASE62_MAX_LENGTH) {
		return -1L;
	}
	List<Range<Character>> ranges = Lists.newArrayList(Range.closed('a', 'z'), 
			Range.closed('0', '9'), Range.closed('A', 'Z'));
	for (int i = 0; i < base62Length; i++) {
		boolean status = false;
		for (Range<Character> range : ranges) {
			if (range.contains(base62.charAt(i))) {
				status = true;
				break;
			}
		}
		
		if (!status) {
			return -1L;
		}
	}
	
	long decimal = 0L;
	for (int i = 0; i < base62Length; i++) {
		int num = ascii2integer(base62.charAt(i));
		decimal += num * Math.pow(BASE, i);
	}
	
	return decimal;
}
 
开发者ID:code4wt,项目名称:short-url,代码行数:31,代码来源:NumberUtils.java

示例6: selectVersion

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Nonnull
private static ABIVersion selectVersion(final ConnectClientRequest message) {
    final Range<ABIVersion> clientRange = Range.closed(message.getMinVersion(), message.getMaxVersion());
    for (ABIVersion v : SUPPORTED_ABIVERSIONS) {
        if (clientRange.contains(v)) {
            return v;
        }
    }

    throw new IllegalArgumentException(String.format(
        "No common version between backend versions %s and client versions %s", SUPPORTED_ABIVERSIONS,
        clientRange));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:Shard.java


注:本文中的com.google.common.collect.Range.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。