下面列出了com.google.common.collect.Multimaps#asMap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Returns the prerequisites keyed by their transition keys. If the split transition is not active
* (e.g. split() returned an empty list), the key is an empty Optional.
*/
public Map<Optional<String>, List<ConfiguredTargetAndData>>
getSplitPrerequisiteConfiguredTargetAndTargets(String attributeName) {
checkAttribute(attributeName, TransitionMode.SPLIT);
// Use an ImmutableListMultimap.Builder here to preserve ordering.
ImmutableListMultimap.Builder<Optional<String>, ConfiguredTargetAndData> result =
ImmutableListMultimap.builder();
List<ConfiguredTargetAndData> deps = getConfiguredTargetAndTargetDeps(attributeName);
for (ConfiguredTargetAndData t : deps) {
ImmutableList<String> transitionKeys = t.getTransitionKeys();
if (transitionKeys.isEmpty()) {
// The split transition is not active, i.e. does not change build configurations.
// TODO(jungjw): Investigate if we need to do a sanity check here.
return ImmutableMap.of(Optional.absent(), deps);
}
for (String key : transitionKeys) {
result.put(Optional.of(key), t);
}
}
return Multimaps.asMap(result.build());
}
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
requireNonNull(prefix, "prefix is null");
ImmutableListMultimap.Builder<SchemaTableName, ColumnMetadata> columns = ImmutableListMultimap.builder();
for (TableColumn tableColumn : dao.listTableColumns(prefix.getSchema().orElse(null), prefix.getTable().orElse(null))) {
ColumnMetadata columnMetadata = new ColumnMetadata(tableColumn.getColumnName(), tableColumn.getDataType());
columns.put(tableColumn.getTable(), columnMetadata);
}
return Multimaps.asMap(columns.build());
}
public void loadMeta(MetaAccumulator meta) {
this.meta = Multimaps.asMap(ImmutableListMultimap.copyOf(meta.getMeta()));
MetaValueSelector metaValueSelector = this.queryOptions.option(MetaValueSelector.KEY)
.orElseGet(() -> this.plugin.getConfiguration().get(ConfigKeys.META_VALUE_SELECTOR));
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Map.Entry<String, List<String>> e : this.meta.entrySet()) {
if (e.getValue().isEmpty()) {
continue;
}
String selected = metaValueSelector.selectValue(e.getKey(), e.getValue());
if (selected == null) {
throw new NullPointerException(metaValueSelector + " returned null");
}
builder.put(e.getKey(), selected);
}
this.flattenedMeta = builder.build();
this.prefixes = ImmutableSortedMap.copyOfSorted(meta.getPrefixes());
this.suffixes = ImmutableSortedMap.copyOfSorted(meta.getSuffixes());
this.weight = meta.getWeight();
this.primaryGroup = meta.getPrimaryGroup();
this.prefixDefinition = meta.getPrefixDefinition();
this.suffixDefinition = meta.getSuffixDefinition();
this.prefix = meta.getPrefix();
this.suffix = meta.getSuffix();
}
/**
* Builds a new instance of {@link THttpService}.
*/
public THttpService build() {
@SuppressWarnings("UnstableApiUsage")
final Map<String, List<Object>> implementations = Multimaps.asMap(implementationsBuilder.build());
final ThriftCallService tcs = ThriftCallService.of(implementations);
return new THttpService(decorate(tcs), newAllowedSerializationFormats(defaultSerializationFormat,
otherSerializationFormats));
}
@Override
public Map<String, List<String>> load(String agentRollupId) throws Exception {
BoundStatement boundStatement = readPS.bind();
boundStatement.setString(0, agentRollupId);
ResultSet results = session.read(boundStatement);
ListMultimap<String, String> traceAttributeNames = ArrayListMultimap.create();
for (Row row : results) {
int i = 0;
String transactionType = checkNotNull(row.getString(i++));
String traceAttributeName = checkNotNull(row.getString(i++));
traceAttributeNames.put(transactionType, traceAttributeName);
}
return Multimaps.asMap(traceAttributeNames);
}
@Override
public Map<String, List<String>> processResultSet(ResultSet resultSet) throws Exception {
ListMultimap<String, String> multimap = ArrayListMultimap.create();
while (resultSet.next()) {
multimap.put(resultSet.getString(1), resultSet.getString(2));
}
return Multimaps.asMap(multimap);
}
@Override
public @NonNull Map<String, Set<String>> toMap() {
return Multimaps.asMap(this.map);
}