本文整理汇总了Java中com.google.common.collect.ImmutableSetMultimap.builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSetMultimap.builder方法的具体用法?Java ImmutableSetMultimap.builder怎么用?Java ImmutableSetMultimap.builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableSetMultimap
的用法示例。
在下文中一共展示了ImmutableSetMultimap.builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSubtyping
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
private static SetMultimap<String, ValueType> buildSubtyping(List<ValueType> implementationTypes) {
ImmutableSetMultimap.Builder<String, ValueType> builder = ImmutableSetMultimap.builder();
for (ValueType type : implementationTypes) {
String abstractValueTypeName = type.typeAbstract().toString();
builder.put(abstractValueTypeName, type);
for (String className : type.getExtendedClassesNames()) {
if (!className.equals(abstractValueTypeName)) {
builder.put(className, type);
}
}
for (String interfaceName : type.getImplementedInterfacesNames()) {
if (!interfaceName.equals(abstractValueTypeName)) {
builder.put(interfaceName, type);
}
}
}
return builder.build();
}
示例2: response2016CollapsedJustifications
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
/**
* Collapses DocEventFrameReferences into their PJs for the particular document at hand.
*/
public static ImmutableSetMultimap<Symbol, QueryResponse2016> response2016CollapsedJustifications(
final Iterable<Map.Entry<Symbol, Collection<DocEventFrameReference>>> matchesByDocument,
final SystemOutputStore2016 store, final CorpusQuery2016 query)
throws IOException {
final ImmutableSetMultimap.Builder<Symbol, QueryResponse2016> retB =
ImmutableSetMultimap.builder();
for (final Map.Entry<Symbol, Collection<DocEventFrameReference>> matchEntry : matchesByDocument) {
final Symbol docID = matchEntry.getKey();
final Collection<DocEventFrameReference> eventFramesMatchedInDoc =
matchEntry.getValue();
final DocumentSystemOutput2015 docSystemOutput = store.read(docID);
final ImmutableSet<CharOffsetSpan> matchJustifications =
matchJustificationsForDoc(eventFramesMatchedInDoc, docSystemOutput);
final QueryResponse2016 queryResponse2016 =
QueryResponse2016.builder().docID(docID).queryID(query.id())
.addAllPredicateJustifications(matchJustifications).build();
retB.put(docID, queryResponse2016);
}
return retB.build();
}
示例3: add
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
public Builder add(final String fieldName, final Collection<String> dependsOnFieldNames, final DependencyType dependencyType)
{
if (dependsOnFieldNames == null || dependsOnFieldNames.isEmpty())
{
return this;
}
ImmutableSetMultimap.Builder<String, String> fieldName2dependsOnFieldNames = type2name2dependencies.get(dependencyType);
if (fieldName2dependsOnFieldNames == null)
{
fieldName2dependsOnFieldNames = ImmutableSetMultimap.builder();
type2name2dependencies.put(dependencyType, fieldName2dependsOnFieldNames);
}
for (final String dependsOnFieldName : dependsOnFieldNames)
{
fieldName2dependsOnFieldNames.put(dependsOnFieldName, fieldName);
}
return this;
}
示例4: buildSourcesIndex
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private PySourcesIndex buildSourcesIndex(Project project, BlazeProjectData projectData) {
ImmutableSetMultimap.Builder<String, QualifiedName> shortNames = ImmutableSetMultimap.builder();
Map<QualifiedName, PsiElementProvider> map = new HashMap<>();
ArtifactLocationDecoder decoder = projectData.artifactLocationDecoder;
for (TargetIdeInfo target : projectData.targetMap.targets()) {
for (ArtifactLocation source : getPySources(target)) {
QualifiedName name = toImportString(source);
if (name == null || name.getLastComponent() == null) {
continue;
}
shortNames.put(name.getLastComponent(), name);
PsiElementProvider psiProvider = psiProviderFromArtifact(decoder, source);
map.put(name, psiProvider);
if (includeParentDirectory(source)) {
map.put(name.removeTail(1), PsiElementProvider.getParent(psiProvider));
}
}
}
return new PySourcesIndex(shortNames.build(), ImmutableMap.copyOf(map));
}
示例5: EqualityInference
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
private EqualityInference(Iterable<Set<Expression>> equalityGroups)
{
ImmutableSetMultimap.Builder<Expression, Expression> setBuilder = ImmutableSetMultimap.builder();
for (Set<Expression> equalityGroup : equalityGroups) {
if (!equalityGroup.isEmpty()) {
setBuilder.putAll(CANONICAL_ORDERING.min(equalityGroup), equalityGroup);
}
}
equalitySets = setBuilder.build();
ImmutableMap.Builder<Expression, Expression> mapBuilder = ImmutableMap.builder();
for (Map.Entry<Expression, Expression> entry : equalitySets.entries()) {
Expression canonical = entry.getKey();
Expression expression = entry.getValue();
mapBuilder.put(expression, canonical);
}
canonicalMap = mapBuilder.build();
}
示例6: mapIndexSourceLookupSymbolToProbeKeyInput
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
/**
* This method creates a mapping from each index source lookup symbol (directly applied to the index)
* to the corresponding probe key Input
*/
private SetMultimap<Symbol, Integer> mapIndexSourceLookupSymbolToProbeKeyInput(IndexJoinNode node, Map<Symbol, Integer> probeKeyLayout)
{
Set<Symbol> indexJoinSymbols = node.getCriteria().stream()
.map(IndexJoinNode.EquiJoinClause::getIndex)
.collect(toImmutableSet());
// Trace the index join symbols to the index source lookup symbols
// Map: Index join symbol => Index source lookup symbol
Map<Symbol, Symbol> indexKeyTrace = IndexJoinOptimizer.IndexKeyTracer.trace(node.getIndexSource(), indexJoinSymbols);
// Map the index join symbols to the probe key Input
Multimap<Symbol, Integer> indexToProbeKeyInput = HashMultimap.create();
for (IndexJoinNode.EquiJoinClause clause : node.getCriteria()) {
indexToProbeKeyInput.put(clause.getIndex(), probeKeyLayout.get(clause.getProbe()));
}
// Create the mapping from index source look up symbol to probe key Input
ImmutableSetMultimap.Builder<Symbol, Integer> builder = ImmutableSetMultimap.builder();
for (Map.Entry<Symbol, Symbol> entry : indexKeyTrace.entrySet()) {
Symbol indexJoinSymbol = entry.getKey();
Symbol indexLookupSymbol = entry.getValue();
builder.putAll(indexLookupSymbol, indexToProbeKeyInput.get(indexJoinSymbol));
}
return builder.build();
}
示例7: getAccountsFor
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
/**
* Returns the accounts for the given emails.
*
* @see #getAccountFor(String)
*/
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
throws IOException, OrmException {
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
externalIds
.byEmails(emails)
.entries()
.stream()
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
queryProvider
.get()
.byPreferredEmail(emails)
.entries()
.stream()
.forEach(e -> builder.put(e.getKey(), e.getValue().getAccount().getId()));
return builder.build();
}
示例8: findExistingTaxCodes
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
/**
* Find tax codes that apply to the items of a given invoice, looking for
* custom fields named {@value #TAX_CODES_FIELD_NAME} that can be attached
* to these items.
*
* @param invoice
* An invoice in which existing tax codes are to be found.
* @return The existing tax codes, grouped by the identifiers of their
* related invoice items. Never {@code null}, and guaranteed not
* having any {@code null} values.
* @throws NullPointerException
* when {@code invoice} is {@code null}.
*/
@Nonnull
public SetMultimap<UUID, TaxCode> findExistingTaxCodes(Invoice invoice) {
Set<CustomField> taxFields = taxFieldsOfInvoices.get(invoice.getId());
// Note: taxFields is not null, by Multimap contract
ImmutableSetMultimap.Builder<UUID, TaxCode> taxCodesOfInvoiceItems = ImmutableSetMultimap.builder();
for (CustomField taxField : taxFields) {
if (!TAX_CODES_FIELD_NAME.equals(taxField.getFieldName())) {
continue;
}
String taxCodesCSV = taxField.getFieldValue();
if (taxCodesCSV == null) {
continue;
}
UUID invoiceItemId = taxField.getObjectId();
Set<TaxCode> taxCodes = cfg.findTaxCodes(taxCodesCSV, "from custom field '" + TAX_CODES_FIELD_NAME
+ "' of invoice item [" + invoiceItemId + "]");
taxCodesOfInvoiceItems.putAll(invoiceItemId, taxCodes);
}
return taxCodesOfInvoiceItems.build();
}
示例9: observeSample
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@Override
public void observeSample(
final Collection<Map<String, FMeasureCounts>> observationSummaries) {
final ImmutableSetMultimap.Builder<String, FMeasureCounts> allCountsB =
ImmutableSetMultimap.builder();
for (final Map<String, FMeasureCounts> observationSummary : observationSummaries) {
allCountsB.putAll(Multimaps.forMap(observationSummary));
}
for (final Map.Entry<String, Collection<FMeasureCounts>> breakdownKeySamples : allCountsB.build().asMap().entrySet()) {
double scoreAggregator = 0.0;
double normalizer = 0.0;
for (final FMeasureCounts fMeasureCounts : breakdownKeySamples.getValue()) {
// per-doc scores clipped at 0
scoreAggregator += Math.max(fMeasureCounts.truePositives()
- alpha()*fMeasureCounts.falsePositives(), 0);
normalizer += fMeasureCounts.truePositives() + fMeasureCounts.falseNegatives();
}
double normalizedScore = 100.0*scoreAggregator/normalizer;
linearScoresB.put(breakdownKeySamples.getKey(), normalizedScore);
}
}
示例10: check
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@Value.Check
protected void check() {
checkArgument(!wrappedModuleParam().isEmpty());
// check for wrapped module bindings which will collide when we strip their own annotations
// and replace them with the wrapping annotation
final ImmutableSetMultimap.Builder<TypeLiteral<?>, Key<?>> externalTypesToInternalTypesB =
ImmutableSetMultimap.builder();
for (final Key<?> key : simpleTypesToWrap()) {
externalTypesToInternalTypesB.put(key.getTypeLiteral(), key);
}
final ImmutableSetMultimap<TypeLiteral<?>, Key<?>> externalTypesToInternalTypes =
externalTypesToInternalTypesB.build();
for (final Map.Entry<TypeLiteral<?>, Collection<Key<?>>> e : externalTypesToInternalTypes
.asMap().entrySet()) {
if (e.getValue().size() > 1) {
throw new IllegalArgumentException("You are exposing multiple inner module bindings which"
+ " will have the same external binding key: " + e.getValue());
}
}
}
示例11: read
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@Override
public ImmutableMultimap<Object, Object> read(
Kryo kryo, Input input, Class<ImmutableMultimap<Object, Object>> type) {
ImmutableMultimap.Builder<Object, Object> builder;
if (type.equals(ImmutableListMultimap.class)) {
builder = ImmutableListMultimap.builder();
} else if (type.equals(ImmutableSetMultimap.class)) {
builder = ImmutableSetMultimap.builder();
} else {
builder = ImmutableMultimap.builder();
}
@SuppressWarnings("unchecked")
Map<Object, Collection<Object>> map = kryo.readObject(input, ImmutableMap.class);
for (Map.Entry<Object, Collection<Object>> entry : map.entrySet()) {
builder.putAll(entry.getKey(), entry.getValue());
}
return builder.build();
}
示例12: createJarResolver
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
private DefaultJavaLibrary.JarResolver createJarResolver(
final ImmutableMap<Path, String> classToSymbols) {
ImmutableSetMultimap.Builder<Path, String> resolveMapBuilder =
ImmutableSetMultimap.builder();
for (Map.Entry<Path, String> entry : classToSymbols.entrySet()) {
String fullyQualified = entry.getValue();
String packageName = fullyQualified.substring(0, fullyQualified.lastIndexOf('.'));
String className = fullyQualified.substring(fullyQualified.lastIndexOf('.'));
resolveMapBuilder.putAll(entry.getKey(), fullyQualified, packageName, className);
}
final ImmutableSetMultimap<Path, String> resolveMap = resolveMapBuilder.build();
return new DefaultJavaLibrary.JarResolver() {
@Override
public ImmutableSet<String> resolve(ProjectFilesystem filesystem, Path relativeClassPath) {
if (resolveMap.containsKey(relativeClassPath)) {
return resolveMap.get(relativeClassPath);
} else {
return ImmutableSet.of();
}
}
};
}
示例13: collectAnnotationOverrides
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
private static Multimap<Class<? extends Annotation>, Class<? extends Annotation>> collectAnnotationOverrides(Iterable<PropertyAnnotationHandler> allAnnotationHandlers) {
ImmutableSetMultimap.Builder<Class<? extends Annotation>, Class<? extends Annotation>> builder = ImmutableSetMultimap.builder();
for (PropertyAnnotationHandler handler : allAnnotationHandlers) {
if (handler instanceof OverridingPropertyAnnotationHandler) {
builder.put(((OverridingPropertyAnnotationHandler) handler).getOverriddenAnnotationType(), handler.getAnnotationType());
}
}
return builder.build();
}
示例14: copyWithTransformedKeys
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@MoveToBUECommon
private static <K1, K2, V> ImmutableSetMultimap<K2, V> copyWithTransformedKeys(
final Multimap<K1,V> setMultimap,
final Function<? super K1, ? extends K2> injection) {
final ImmutableSetMultimap.Builder<K2,V> ret = ImmutableSetMultimap.builder();
for (final Map.Entry<K1, V> entry : setMultimap.entries()) {
ret.put(checkNotNull(injection.apply(entry.getKey())), entry.getValue());
}
return ret.build();
}
示例15: transformKeys
import com.google.common.collect.ImmutableSetMultimap; //导入方法依赖的package包/类
@MoveToBUECommon
private static <K1, K2, V> ImmutableSetMultimap<K2, V> transformKeys(Map<K1, V> input,
Function<? super K1, ? extends K2> function) {
final ImmutableSetMultimap.Builder<K2, V> ret = ImmutableSetMultimap.builder();
for (final Map.Entry<K1, V> entry : input.entrySet()) {
ret.put(checkNotNull(function.apply(entry.getKey())), entry.getValue());
}
return ret.build();
}