本文整理汇总了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));
}
示例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));
}
示例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;
}
}
示例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;
}
示例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)));
}