本文整理汇总了Java中com.google.common.collect.Multimaps.transformValues方法的典型用法代码示例。如果您正苦于以下问题:Java Multimaps.transformValues方法的具体用法?Java Multimaps.transformValues怎么用?Java Multimaps.transformValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multimaps
的用法示例。
在下文中一共展示了Multimaps.transformValues方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeToString
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private String computeToString() {
StringBuilder builder = new StringBuilder().append(type).append('/').append(subtype);
if (!parameters.isEmpty()) {
builder.append("; ");
Multimap<String, String> quotedParameters =
Multimaps.transformValues(
parameters,
new Function<String, String>() {
@Override
public String apply(String value) {
return TOKEN_MATCHER.matchesAllOf(value) ? value : escapeAndQuote(value);
}
});
PARAMETER_JOINER.appendTo(builder, quotedParameters.entries());
}
return builder.toString();
}
示例2: getTasksByHosts
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Multimap<String, String> getTasksByHosts(StoreProvider provider, Iterable<String> hosts) {
if (Iterables.isEmpty(hosts)) {
return ImmutableMultimap.of();
}
ImmutableSet.Builder<IScheduledTask> drainingTasks = ImmutableSet.builder();
drainingTasks.addAll(provider.getTaskStore()
.fetchTasks(Query.slaveScoped(hosts).byStatus(Tasks.SLAVE_ASSIGNED_STATES)));
return Multimaps.transformValues(
Multimaps.index(drainingTasks.build(), Tasks::scheduledToSlaveHost),
Tasks::id);
}
示例3: assertState
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private void assertState(
JobUpdateStatus expected,
Multimap<Integer, JobUpdateAction> expectedActions) {
IJobUpdateDetails details = getDetails();
Iterable<IJobInstanceUpdateEvent> orderedEvents =
EVENT_ORDER.sortedCopy(details.getInstanceEvents());
Multimap<Integer, IJobInstanceUpdateEvent> eventsByInstance =
Multimaps.index(orderedEvents, EVENT_TO_INSTANCE);
Multimap<Integer, JobUpdateAction> actionsByInstance =
Multimaps.transformValues(eventsByInstance, JobUpdateControllerImpl.EVENT_TO_ACTION);
assertEquals(expectedActions, actionsByInstance);
assertEquals(expected, details.getUpdate().getSummary().getState().getStatus());
}
示例4: computeToString
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private String computeToString() {
StringBuilder builder = new StringBuilder().append(type).append('/').append(subtype);
if (!parameters.isEmpty()) {
builder.append("; ");
Multimap<String, String> quotedParameters = Multimaps.transformValues(parameters, new Function<String, String>() {
@Override
public String apply(String value) {
return TOKEN_MATCHER.matchesAllOf(value) ? value : escapeAndQuote(value);
}
});
PARAMETER_JOINER.appendTo(builder, quotedParameters.entries());
}
return builder.toString();
}
示例5: apply
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public TestHistoryDifferenceDescription apply(@Nonnull AbstractHistoryDifference<?, ?> input) {
return new TestHistoryDifferenceDescription(
input.getEventType(),
Multimaps.transformValues(
Multimaps.index(input.getDifferences(), HISTORY_DIFFERENCE_TO_DIFFERENCE_KEY),
HISTORY_DIFFERENCE_TO_DESCRIPTION // Recursion. On suppose qu'il n'y a pas de cycle.
)
);
}
示例6: toString
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
* Returns the string representation of this media type in the format described in <a
* href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>.
*/
@Override public String toString() {
StringBuilder builder = new StringBuilder().append(type).append('/').append(subtype);
if (!parameters.isEmpty()) {
builder.append("; ");
Multimap<String, String> quotedParameters = Multimaps.transformValues(parameters,
new Function<String, String>() {
@Override public String apply(String value) {
return TOKEN_MATCHER.matchesAllOf(value) ? value : escapeAndQuote(value);
}
});
PARAMETER_JOINER.appendTo(builder, quotedParameters.entries());
}
return builder.toString();
}
示例7: outputSymbolMap
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
* Returns the input to output symbol mapping for the given source channel.
* A single input symbol can map to multiple output symbols, thus requiring a Multimap.
*/
public Multimap<Symbol, QualifiedNameReference> outputSymbolMap(int sourceIndex)
{
return Multimaps.transformValues(FluentIterable.from(getOutputSymbols())
.toMap(outputToSourceSymbolFunction(sourceIndex))
.asMultimap()
.inverse(), Symbol::toQualifiedNameReference);
}
示例8: computeToString
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private String computeToString() {
StringBuilder builder = new StringBuilder().append(type).append('/').append(subtype);
if (!parameters.isEmpty()) {
builder.append("; ");
Multimap<String, String> quotedParameters =
Multimaps.transformValues(
parameters,
value -> TOKEN_MATCHER.matchesAllOf(value) ? value : escapeAndQuote(value));
PARAMETER_JOINER.appendTo(builder, quotedParameters.entries());
}
return builder.toString();
}
示例9: getVictims
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Multimap<String, PreemptionVictim> getVictims(IScheduledTask... tasks) {
return Multimaps.transformValues(
Multimaps.index(Arrays.asList(tasks), task -> task.getAssignedTask().getSlaveId()),
task -> PreemptionVictim.fromTask(task.getAssignedTask())
);
}
示例10: description
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Multimap<TestHistoryDifferenceKey, TestHistoryDifferenceDescription> description(Collection<D> collection) {
return Multimaps.transformValues(
Multimaps.index(collection, HISTORY_DIFFERENCE_TO_DIFFERENCE_KEY),
HISTORY_DIFFERENCE_TO_DESCRIPTION
);
}
示例11: transformRefs
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private static ListMultimap<ObjectId, PatchSet.Id> transformRefs(
ListMultimap<ObjectId, Ref> refs) {
return Multimaps.transformValues(refs, r -> PatchSet.Id.fromRef(r.getName()));
}
示例12: convertCurrentPojoLinksToPseudoLines
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Multimap<String, String> convertCurrentPojoLinksToPseudoLines(
Multimap<String, PojoData> requestedPojosByName,
Map<Long, Collection<TagAnnotationData>> databasePojosTagsLinks,
Collection<PojoData> experimenterPojos) throws ServerError {
Check.notEmpty(requestedPojosByName.asMap(), "requestedPojosByName");
Check.notEmpty(experimenterPojos, "experimenterPojos");
// transform the tags-pojos pairs coming from the database into "lines"
// for comparison with the csv file
// ie. switch from the map of already linked datasets/images-tags with:
// key=pojo_id and values=[tags]
// to a multimap of character strings with:
// key=tag and values=[pojo_names]:
// <Long>, [TagAnnotationData] -> <String>, [TagAnnotationData] -> <String>, [String] -> invert
log.trace("requestedPojosByName: {}",
requestedPojosByName.size(), requestedPojosByName);
// convert the query result to a multimap for convenient manipulation
Multimap<Long, TagAnnotationData> dbPojoTagsMultimap = fromTagsMap(databasePojosTagsLinks);
// keep their name only: key=pojo_id, values=[attached_tag_names]
Multimap<Long, String> dbPojoIdToTagNames =
Multimaps.transformValues(dbPojoTagsMultimap, FunctionsUtil.toTagValue);
// then, convert to name-names multimap: key=pojo_name, values=[attached_tag_names]
Multimap<String, String> dbPojoNameToTagNames = HashMultimap.create();
Map<Long, PojoData> availablePojosById = indexById(experimenterPojos);
for (Long pojoId : dbPojoIdToTagNames.keySet()) {
Collection<String> unchangedTagNames = dbPojoIdToTagNames.get(pojoId);
if (availablePojosById.containsKey(pojoId)) {
PojoData pojo = availablePojosById.get(pojoId);
String pojoName = pojo.getName();
dbPojoNameToTagNames.putAll(pojoName, unchangedTagNames);
} else {
log.error("ERROR - Unable to map pojo id {} to name - inconsistent state", pojoId);
}
}
log.debug("dbPojoNameToTagNames: {} - {}",
dbPojoNameToTagNames.size(), dbPojoNameToTagNames);
// provide the inverse mapping again to make sure both maps are comparable
Multimap<String, String> dbTagNameToPojosNames = invertKeyValues(dbPojoNameToTagNames);
log.debug("dbTagNameToPojosNames: {} - {}",
dbTagNameToPojosNames.size(), dbTagNameToPojosNames);
return dbTagNameToPojosNames;
}
示例13: getConfiguredTargetMap
import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
* Returns an immutable map from attribute name to list of configured targets for that attribute.
*/
public ListMultimap<String, ? extends TransitiveInfoCollection> getConfiguredTargetMap() {
return Multimaps.transformValues(targetMap, ConfiguredTargetAndTarget::getConfiguredTarget);
}