本文整理匯總了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);
}