Java 类com.google.common.collect.MultimapBuilder.ListMultimapBuilder 实例源码

项目:bazel    文件:ProfileInfo.java   
/**
 * 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);
    }
  }
}
项目:lumen-kb    文件:YagoEntityByLabelCacheStore.java   
@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);
}
项目:NucleusFramework    文件:PlayerListMultimap.java   
/**
 * Constructor.
 *
 * @param plugin   The owning plugin.
 */
public PlayerListMultimap(Plugin plugin) {
    super(plugin);

    _map = ListMultimapBuilder.hashKeys().arrayListValues().build();
}