本文整理汇总了Java中com.google.common.collect.Multimap.asMap方法的典型用法代码示例。如果您正苦于以下问题:Java Multimap.asMap方法的具体用法?Java Multimap.asMap怎么用?Java Multimap.asMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multimap
的用法示例。
在下文中一共展示了Multimap.asMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectExternalProjectDependents
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Sugar for collecting {@link IWorkspace Eclipse workspace} projects that have any direct dependency to any
* external projects. Same as {@link #collectExternalProjectDependents()} but does not consider all the available
* projects but only those that are given as the argument.
*
* @param externalProjects
* the external projects that has to be considered as a possible dependency of an Eclipse workspace based
* project.
* @return a map where each entry maps an external project to the workspace projects that depend on it.
*/
public Map<IProject, Collection<IProject>> collectExternalProjectDependents(
final Iterable<? extends IProject> externalProjects) {
final Multimap<IProject, IProject> mapping = Multimaps2.newLinkedHashListMultimap();
if (Platform.isRunning()) {
final Map<String, IProject> externalsMapping = new HashMap<>();
externalProjects.forEach(p -> externalsMapping.put(p.getName(), p));
asList(getWorkspace().getRoot().getProjects()).forEach(p -> {
getDirectExternalDependencyIds(p).forEach(eID -> {
IProject externalDependency = externalsMapping.get(eID);
if (externalDependency != null) {
mapping.put(externalDependency, p);
}
});
});
}
return mapping.asMap();
}
示例2: groupBySubject
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private Map<Node, Collection<Triple>> groupBySubject(Set<Triple> triples) {
Multimap<Node, Triple> subject2Triples = HashMultimap.create();
for (Triple triple : triples) {
subject2Triples.put(triple.getSubject(), triple);
}
return subject2Triples.asMap();
}
示例3: serialize
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
@Override
public JsonElement serialize(Multimap<String, ?> src, Type type, JsonSerializationContext context)
{
final Map<?, ?> map = src.asMap();
return context.serialize(map);
}