當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。