List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:org.caleydo.view.domino.internal.data.Categorical2DDataDomainValues.java
/** * @param dimGroups2//w w w .ja v a 2s . c om * @param categories * @param idType * @return */ private TypedGroupSet toGroups(Multimap<Object, Integer> groups, List<CategoryProperty<?>> categories, IDType idType) { List<TypedSetGroup> r = new ArrayList<>(categories.size()); for (CategoryProperty<?> category : categories) { Collection<Integer> ids = groups.get(category.getCategory()); if (ids == null || ids.isEmpty()) continue; r.add(new TypedSetGroup(ImmutableSet.copyOf(ids), idType, category.getCategoryName(), category.getColor())); } return new TypedGroupSet(ImmutableList.copyOf(r)); }
From source file:eu.tomylobo.routes.infrastructure.Route.java
public void load(Multimap<String, Multimap<String, String>> sections) { final String routeSectionName = "route " + name; final Multimap<String, String> routeSection = Ini.getOnlyValue(sections.get(routeSectionName)); world = Ini.loadWorld(routeSection, "%s"); int nNodes = Ini.getOnlyInt(routeSection.get("nodes")); nodes.clear();//from w w w. ja v a 2s .com ((ArrayList<Node>) nodes).ensureCapacity(nNodes); for (int i = 0; i < nNodes; ++i) { final String nodeName = name + "-" + i; addNodes(new Node(sections, nodeName)); } setDirty(); }
From source file:org.artifactory.search.deployable.VersionUnitSearcher.java
private Set<VersionUnitSearchResult> getVersionUnitResults( Multimap<ModuleInfo, RepoPath> moduleInfoToRepoPaths) { Set<VersionUnitSearchResult> searchResults = Sets.newHashSet(); for (ModuleInfo moduleInfo : moduleInfoToRepoPaths.keySet()) { searchResults.add(new VersionUnitSearchResult( new VersionUnit(moduleInfo, Sets.newHashSet(moduleInfoToRepoPaths.get(moduleInfo))))); }/*from w w w. ja v a 2 s. c o m*/ return searchResults; }
From source file:org.sonar.server.computation.filemove.FileMoveDetectionStep.java
private static ElectedMatches electMatches(Set<String> dbFileKeys, Map<String, File> reportFileSourcesByKey, MatchesByScore matchesByScore) { ElectedMatches electedMatches = new ElectedMatches(matchesByScore, dbFileKeys, reportFileSourcesByKey); Multimap<String, Match> matchesPerFileForScore = ArrayListMultimap.create(); for (List<Match> matches : matchesByScore) { // no match for this score value, ignore if (matches == null) { continue; }//from w w w . j a v a2 s . c o m List<Match> matchesToValidate = electedMatches.filter(matches); if (matches.isEmpty()) { continue; } if (matches.size() == 1) { Match match = matches.get(0); electedMatches.add(match); } else { matchesPerFileForScore.clear(); for (Match match : matches) { matchesPerFileForScore.put(match.getDbKey(), match); matchesPerFileForScore.put(match.getReportKey(), match); } // validate non ambiguous matches (ie. the match is the only match of either the db file and the report file) for (Match match : matchesToValidate) { int dbFileMatchesCount = matchesPerFileForScore.get(match.getDbKey()).size(); int reportFileMatchesCount = matchesPerFileForScore.get(match.getReportKey()).size(); if (dbFileMatchesCount == 1 && reportFileMatchesCount == 1) { electedMatches.add(match); } } } } return electedMatches; }
From source file:cuchaz.enigma.convert.MappingsConverter.java
public static Mappings newMappings(ClassMatches matches, Mappings oldMappings, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) { // sort the unique matches by size of inner class chain Multimap<Integer, java.util.Map.Entry<ClassEntry, ClassEntry>> matchesByDestChainSize = HashMultimap .create();/*from ww w .jav a 2 s . co m*/ for (java.util.Map.Entry<ClassEntry, ClassEntry> match : matches.getUniqueMatches().entrySet()) { int chainSize = destDeobfuscator.getJarIndex().getObfClassChain(match.getValue()).size(); matchesByDestChainSize.put(chainSize, match); } // build the mappings (in order of small-to-large inner chains) Mappings newMappings = new Mappings(); List<Integer> chainSizes = Lists.newArrayList(matchesByDestChainSize.keySet()); Collections.sort(chainSizes); for (int chainSize : chainSizes) { for (java.util.Map.Entry<ClassEntry, ClassEntry> match : matchesByDestChainSize.get(chainSize)) { // get class info ClassEntry obfSourceClassEntry = match.getKey(); ClassEntry obfDestClassEntry = match.getValue(); List<ClassEntry> destClassChain = destDeobfuscator.getJarIndex() .getObfClassChain(obfDestClassEntry); ClassMapping sourceMapping = sourceDeobfuscator.getMappings().getClassByObf(obfSourceClassEntry); if (sourceMapping == null) { // if this class was never deobfuscated, don't try to match it continue; } // find out where to make the dest class mapping if (destClassChain.size() == 1) { // not an inner class, add directly to mappings newMappings .addClassMapping(migrateClassMapping(obfDestClassEntry, sourceMapping, matches, false)); } else { // inner class, find the outer class mapping ClassMapping destMapping = null; for (int i = 0; i < destClassChain.size() - 1; i++) { ClassEntry destChainClassEntry = destClassChain.get(i); if (destMapping == null) { destMapping = newMappings.getClassByObf(destChainClassEntry); if (destMapping == null) { destMapping = new ClassMapping(destChainClassEntry.getName()); newMappings.addClassMapping(destMapping); } } else { destMapping = destMapping .getInnerClassByObfSimple(destChainClassEntry.getInnermostClassName()); if (destMapping == null) { destMapping = new ClassMapping(destChainClassEntry.getName()); destMapping.addInnerClassMapping(destMapping); } } } destMapping.addInnerClassMapping( migrateClassMapping(obfDestClassEntry, sourceMapping, matches, true)); } } } return newMappings; }
From source file:io.takari.maven.plugins.jar.Jar.java
private List<Entry> inputsSource(Multimap<File, File> inputs) { final List<Entry> entries = new ArrayList<>(); for (File basedir : inputs.keySet()) { entries.addAll(inputsSource(basedir, inputs.get(basedir))); }//from www. j av a 2s .c om return entries; }
From source file:org.jboss.errai.ioc.rebind.ioc.bootstrapper.ProviderFactoryBodyGenerator.java
@Override protected List<Statement> generateCreateInstanceStatements(final ClassStructureBuilder<?> bodyBlockBuilder, final Injectable injectable, final DependencyGraph graph, InjectionContext injectionContext) { final Multimap<DependencyType, Dependency> dependenciesByType = separateByType( injectable.getDependencies()); assert dependenciesByType.size() == 1 : "The factory " + injectable.getFactoryName() + " is a Provider and should have exactly one dependency"; final Collection<Dependency> providerInstanceDeps = dependenciesByType.get(DependencyType.ProducerMember); assert providerInstanceDeps.size() == 1 : "The factory " + injectable.getFactoryName() + " is a Provider but does not have a " + DependencyType.ProducerMember.toString() + " depenency."; final Dependency providerDep = providerInstanceDeps.iterator().next(); final List<Statement> createInstanceStatements = getAndInvokeProvider(injectable, providerDep); return createInstanceStatements; }
From source file:com.android.tools.lint.checks.ViewTypeDetector.java
@Nullable protected Collection<String> getViewTags(@NonNull Context context, @NonNull ResourceItem item) { // Check view tag in this file. Can I do it cheaply? Try with // an XML pull parser. Or DOM if we have multiple resources looked // up?//from w w w . j a v a 2 s .c om ResourceFile source = item.getSource(); if (source != null) { File file = source.getFile(); Multimap<String, String> map = getIdToTagsIn(context, file); if (map != null) { return map.get(item.getName()); } } return null; }
From source file:org.apache.storm.metric.FakeMetricConsumer.java
@Override public void handleDataPoints(TaskInfo taskInfo, Collection<DataPoint> dataPoints) { synchronized (buffer) { for (DataPoint dp : dataPoints) { for (Map.Entry<String, Object> entry : expandComplexDataPoint(dp).entrySet()) { String metricName = entry.getKey(); Multimap<Integer, Object> taskIdToBucket = buffer.get(taskInfo.srcComponentId, metricName); if (null == taskIdToBucket) { taskIdToBucket = ArrayListMultimap.create(); taskIdToBucket.put(taskInfo.srcTaskId, entry.getValue()); } else { taskIdToBucket.get(taskInfo.srcTaskId).add(entry.getValue()); }//from w w w .j av a 2 s . c om buffer.put(taskInfo.srcComponentId, metricName, taskIdToBucket); } } } }
From source file:org.javersion.store.jdbc.DocumentVersionStoreJdbc.java
protected void doAppend(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId) { DocumentUpdateBatch<Id, M, V> batch = updateBatch(versionsByDocId.keys()); for (Id docId : versionsByDocId.keySet()) { for (VersionNode<PropertyPath, Object, M> version : versionsByDocId.get(docId)) { batch.addVersion(docId, version); }//from w ww . j av a2 s .c o m } batch.execute(); }