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


Java Maps.filterKeys方法代码示例

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


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

示例1: resolve

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public ImmutableMap<String, BuildRule> resolve(Set<String> classes) {
  ImmutableSet<String> projectClasses =
      classes.stream().filter(name -> whiteList.matcher(name).find()).collect(toImmutableSet());

  Map<String, Path> classToSrcFileMap =
      Maps.filterKeys(classToFile, k -> projectClasses.contains(k));

  handleUnresolvedClasses(projectClasses, classToSrcFileMap.keySet());

  ImmutableGraph<String> resolvedClassGraph =
      ImmutableGraph.copyOf(Graphs.inducedSubgraph(classGraph, classToSrcFileMap.keySet()));

  ImmutableGraph<Path> srcFileGraph =
      ClassToSourceGraphConsolidator.map(resolvedClassGraph, classToSrcFileMap);

  ImmutableGraph<ImmutableSet<Path>> componentDAG =
      new StronglyConnectedComponents<>(srcFileGraph).computeComponentDAG();

  return ImmutableMap.copyOf(
      mapClassToBuildRule(componentDAG, classToSrcFileMap, resolvedClassGraph));
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:23,代码来源:ProjectClassToRuleResolver.java

示例2: getByPrefix

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * A settings that are filtered (and key is removed) with the specified prefix.
 */
public Settings getByPrefix(String prefix) {
    if (!prefix.endsWith(".")) {
        prefix += ".";
    }
    String _prefix = prefix;
    Map<String, String> sub = Maps.filterKeys(settings, key -> key.startsWith(_prefix));

    HashMap<String, String> result = Maps.newHashMap();

    for (Map.Entry<String, String> entry : sub.entrySet()) {
        result.put(entry.getKey().substring(_prefix.length()), entry.getValue());
    }

    return new Settings(ImmutableMap.copyOf(result));
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:19,代码来源:Settings.java

示例3: buildHeaders

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * 将headers合成一个字符串
 * 需要注意的是,HTTP头需要按照字母排序加入签名字符串
 * 同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers"
 *
 */
private static String buildHeaders(Map<String, String> headers) {

    if (MapUtils.isNotEmpty(headers)) {
        // 筛选出需要签名的key
        Predicate<String> signFilter = new Predicate<String>() {
            @Override
            public boolean apply(String input) {
                return input.startsWith(SdkConstant.CLOUDAPI_CA_HEADER_TO_SIGN_PREFIX_SYSTEM);
            }
        };

        // 使用TreeMap,默认按照字母排序
        Map<String, String> headersToSign = new TreeMap<String, String>(Maps.filterKeys(headers, signFilter));

        // 所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers"
        String signHeaders = Joiner.on(',').join(headersToSign.keySet());
        headers.put(SdkConstant.CLOUDAPI_X_CA_SIGNATURE_HEADERS, signHeaders);

        // 拼装签名内容
        Joiner.MapJoiner joiner = Joiner.on(SdkConstant.CLOUDAPI_LF).withKeyValueSeparator(':');
        return joiner.join(headersToSign);

    } else {
        return StringUtils.EMPTY;
    }


}
 
开发者ID:aliyun,项目名称:apigateway-sdk-core,代码行数:35,代码来源:SignUtil.java

示例4: dropCapabilities

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private static Capabilities dropCapabilities(Capabilities capabilities, String... keysToRemove) {
    if (capabilities == null) {
        return new DesiredCapabilities();
    }
    final Set<String> toRemove = Sets.newHashSet(keysToRemove);
    DesiredCapabilities caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate<String>() {
        @Override public boolean apply(String key) {
            return !toRemove.contains(key);
        }
    }));

    return caps;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaDriver.java

示例5: from

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * retains only metadata pertaining to responses for which we have a score.
 */
public static ArgumentOutput from(final Symbol docId,
    final Iterable<Scored<Response>> scoredResponses, final Map<Response, String> metadata) {
  ImmutableSet<Response> responses =
      ImmutableSet.copyOf(transform(scoredResponses, Scoreds.<Response>itemsOnly()));
  return new ArgumentOutput(docId, responses, Scoreds.asMapKeepingHigestScore(scoredResponses),
      Maps.filterKeys(metadata, Predicates.in(responses)));
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:11,代码来源:ArgumentOutput.java


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