本文整理汇总了Java中com.google.common.collect.MultimapBuilder.ListMultimapBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ListMultimapBuilder类的具体用法?Java ListMultimapBuilder怎么用?Java ListMultimapBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListMultimapBuilder类属于com.google.common.collect.MultimapBuilder包,在下文中一共展示了ListMultimapBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateSkylarkStatistics
import com.google.common.collect.MultimapBuilder.ListMultimapBuilder; //导入依赖的package包/类
/**
* Collects all Skylark function tasks. Must be called before calling
* {@link #getSkylarkUserFunctionTasks} and {@link #getSkylarkBuiltinFunctionTasks}.
*/
private void calculateSkylarkStatistics() {
userFunctions = ListMultimapBuilder.treeKeys().arrayListValues().build();
compiledUserFunctions = ListMultimapBuilder.treeKeys().arrayListValues().build();
builtinFunctions = ListMultimapBuilder.treeKeys().arrayListValues().build();
for (Task task : allTasksById) {
if (task.type == ProfilerTask.SKYLARK_BUILTIN_FN) {
builtinFunctions.put(task.getDescription(), task);
} else if (task.type == ProfilerTask.SKYLARK_USER_FN) {
userFunctions.put(task.getDescription(), task);
} else if (task.type == ProfilerTask.SKYLARK_USER_COMPILED_FN) {
compiledUserFunctions.put(task.getDescription(), task);
}
}
}
示例2: loadAll
import com.google.common.collect.MultimapBuilder.ListMultimapBuilder; //导入依赖的package包/类
@Override
public void loadAll(GridCacheTx tx, Collection<? extends String> keys,
GridBiInClosure<String, ListMultimap<String, String>> c) throws GridException {
ImmutableMap<? extends String, ListMultimap<String, String>> resultMap = Maps.toMap(keys,
(it) -> ListMultimapBuilder.<String, String>hashKeys().arrayListValues().build());
String quoteds = Joiner.on('|').join( keys.stream().map((it) -> Pattern.quote(it)).collect(Collectors.toList()) );
Pattern pattern = Pattern.compile("^(" + quoteds + ")$", Pattern.CASE_INSENSITIVE);
ImmutableList<ImmutableMap<String, Pattern>> crits = ImmutableList.of(
ImmutableMap.of("p", pattern),
ImmutableMap.of("l", pattern),
ImmutableMap.of("m", pattern),
ImmutableMap.of("g", pattern),
ImmutableMap.of("f", pattern) );
BasicDBObject crit = new BasicDBObject("$or", crits);
log.debug("Finding {} : {}", keys, crit);
try (DBCursor cursor = labelColl.find(crit).setReadPreference(ReadPreference.secondaryPreferred())) {
for (DBObject dbo : cursor) {
String entityId = (String) dbo.get("_id");
final YagoLabel label = toYagoLabel(dbo);
for (String key : keys) {
final ListMultimap<String, String> labelResult = resultMap.get(key);
if (label.getPreferredMeaningLabels() != null && label.getPreferredMeaningLabels().stream().anyMatch( (it) -> it.equalsIgnoreCase(key) )) {
log.debug("{} isPreferredMeaningOf {}", entityId, key);
// if has isPreferredMeaningOf, then this entity is prioritized for this label
labelResult.get("_").remove(entityId);
labelResult.get("_").add(0, entityId);
} else if (!labelResult.get("_").contains(entityId)) {
if (StringUtils.equalsIgnoreCase(key, label.getPrefLabel()) ||
label.getLabels().stream().anyMatch( (it) -> it.equalsIgnoreCase(key) ) ||
StringUtils.equalsIgnoreCase(key, label.getGivenName()) ||
StringUtils.equalsIgnoreCase(key, label.getFamilyName()) ) {
labelResult.get("_").add(entityId);
}
}
}
}
}
resultMap.forEach(c::apply);
}
示例3: PlayerListMultimap
import com.google.common.collect.MultimapBuilder.ListMultimapBuilder; //导入依赖的package包/类
/**
* Constructor.
*
* @param plugin The owning plugin.
*/
public PlayerListMultimap(Plugin plugin) {
super(plugin);
_map = ListMultimapBuilder.hashKeys().arrayListValues().build();
}