List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:org.deephacks.tools4j.config.internal.core.jpa.JpaBean.java
private static Set<BeanId> uniqueSet(Multimap<BeanId, JpaRef> refs) { Set<BeanId> ids = new HashSet<BeanId>(); for (BeanId id : refs.keySet()) { ids.add(id);//from w w w .j a v a2 s . c om for (JpaRef ref : refs.get(id)) { ids.add(ref.getTarget()); } } return ids; }
From source file:com.eucalyptus.cloudwatch.domain.metricdata.MetricManager.java
private static void addManyMetrics(Multimap<Class, MetricEntity> metricMap) { for (Class c : metricMap.keySet()) { EntityTransaction db = Entities.get(c); try {//from ww w. j a v a 2 s.c o m for (MetricEntity me : metricMap.get(c)) { Entities.persist(me); } db.commit(); } catch (RuntimeException ex) { Logs.extreme().error(ex, ex); throw ex; } finally { if (db.isActive()) db.rollback(); } } }
From source file:org.hudsonci.plugins.vault.util.MultimapUtil.java
public static void save(final Multimap<String, String> map, final Writer target, final String sep) throws IOException { assert map != null; assert target != null; if (map.isEmpty()) { return;//from w ww .j av a 2 s .c o m } PrintWriter writer = new PrintWriter(new BufferedWriter(target)); for (String key : map.keySet()) { for (String value : map.get(key)) { writer.append(key).append('=').append(value).append(sep); } } writer.flush(); }
From source file:com.evolveum.midpoint.util.ClassPathUtil.java
/** * This is not entirely reliable method. * Maybe it would be better to rely on Spring ClassPathScanningCandidateComponentProvider *//*from w w w .j ava 2 s. c om*/ public static void searchClasses(String packageName, Consumer<Class> consumer) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setScanners(new SubTypesScanner(false)); builder.setUrls(ClasspathHelper.forPackage(packageName, LOGGER.getClass().getClassLoader())); builder.setInputsFilter(new FilterBuilder().includePackage(packageName)); Reflections reflections = new Reflections(builder); Multimap<String, String> map = reflections.getStore().get(SubTypesScanner.class.getSimpleName()); Set<String> types = new HashSet<>(); for (String key : map.keySet()) { Collection<String> col = map.get(key); if (col == null) { continue; } for (String c : col) { String simpleName = c.replaceFirst(packageName + "\\.", ""); if (simpleName.contains(".")) { continue; } types.add(c); } } for (String type : types) { try { Class clazz = Class.forName(type); consumer.accept(clazz); } catch (ClassNotFoundException e) { LOGGER.error("Error during loading class {}. ", type); } } }
From source file:com.paolodragone.wsn.util.Senses.java
public static ListMultimap<String, Sense> buildWordSensesMap(Collection<Sense> senses) { Multimap<String, Sense> wordSensesMap = ArrayListMultimap.create(); ListMultimap<String, Sense> wordSensesSortedMap = ArrayListMultimap.create(); for (Sense sense : senses) { wordSensesMap.put(sense.getWord().toLowerCase(), sense); }//from w w w. ja va2 s . com for (String word : wordSensesMap.keySet()) { List<Sense> senseList = new ArrayList<>(wordSensesMap.get(word)); sortSenseList(senseList); wordSensesSortedMap.putAll(word, senseList); } return wordSensesSortedMap; }
From source file:grakn.core.graql.reasoner.plan.GraqlTraversalPlanner.java
/** * * @param atoms list of current atoms of interest * @param queryPattern corresponding pattern * @return an optimally ordered list of provided atoms *///from www . j a v a 2s . c o m private static ImmutableList<Atom> planFromTraversal(List<Atom> atoms, Conjunction<?> queryPattern, TransactionOLTP tx) { Multimap<VarProperty, Atom> propertyMap = HashMultimap.create(); atoms.stream().filter(atom -> !(atom instanceof OntologicalAtom)) .forEach(atom -> atom.getVarProperties().forEach(property -> propertyMap.put(property, atom))); Set<VarProperty> properties = propertyMap.keySet(); GraqlTraversal graqlTraversal = TraversalPlanner.createTraversal(queryPattern, tx); ImmutableList<Fragment> fragments = Iterables.getOnlyElement(graqlTraversal.fragments()); List<Atom> atomList = new ArrayList<>(); atoms.stream().filter(atom -> atom instanceof OntologicalAtom).forEach(atomList::add); fragments.stream().map(Fragment::varProperty).filter(Objects::nonNull).filter(properties::contains) .distinct().flatMap(property -> propertyMap.get(property).stream()).distinct() .forEach(atomList::add); //add any unlinked items (disconnected and indexed for instance) propertyMap.values().stream().filter(at -> !atomList.contains(at)).forEach(atomList::add); return ImmutableList.copyOf(atomList); }
From source file:com.android.tools.idea.navigator.nodes.NdkModuleNode.java
@NotNull public static Collection<AbstractTreeNode> getNativeSourceNodes(@NotNull Project project, @NotNull NdkModuleModel ndkModuleModel, @NotNull ViewSettings viewSettings) { NativeAndroidProject nativeAndroidProject = ndkModuleModel.getAndroidProject(); Collection<String> sourceFileExtensions = nativeAndroidProject.getFileExtensions().keySet(); NdkModuleModel.NdkVariant variant = ndkModuleModel.getSelectedVariant(); Multimap<String, NativeArtifact> nativeLibraries = HashMultimap.create(); for (NativeArtifact artifact : variant.getArtifacts()) { String artifactOutputFileName = artifact.getOutputFile().getName(); nativeLibraries.put(artifactOutputFileName, artifact); }//ww w .j a v a 2s.c o m if (nativeLibraries.keySet().size() == 1) { return getSourceDirectoryNodes(project, nativeLibraries.values(), viewSettings, sourceFileExtensions); } List<AbstractTreeNode> children = Lists.newArrayList(); for (String name : nativeLibraries.keySet()) { String nativeLibraryType = ""; String nativeLibraryName = trimEnd(name, ".so"); if (nativeLibraryName.length() < name.length()) { nativeLibraryType = "Shared Library"; } else { nativeLibraryName = trimEnd(name, ".a"); if (nativeLibraryName.length() < name.length()) { nativeLibraryType = "Static Library"; } } nativeLibraryName = trimStart(nativeLibraryName, "lib"); children.add(new NativeAndroidLibraryNode(project, nativeLibraryName, nativeLibraryType, nativeLibraries.get(name), viewSettings, sourceFileExtensions)); } return children; }
From source file:com.torodb.torod.db.postgresql.meta.routines.DeleteDocuments.java
public static int execute(Configuration configuration, CollectionSchema colSchema, Multimap<DocStructure, Integer> didsByStructure) throws SQLException { TableProvider tableProvider = new TableProvider(colSchema); DSLContext dsl = DSL.using(configuration); Set<SubDocTable> tables = Sets.newHashSet(); for (DocStructure structure : didsByStructure.keySet()) { tables.clear();/* w w w. ja v a2 s. c o m*/ structure.accept(tableProvider, tables); executeDeleteSubDocuments(dsl, tables, didsByStructure.get(structure)); } Set<Integer> dids = Sets.newHashSet(didsByStructure.values()); return executeDeleteRoots(dsl, colSchema, dids); }
From source file:org.icgc.dcc.release.job.annotate.converter.SnpEffVCFToICGCConverter.java
/** * Returns a set of effects sorted by priority and limited by 1 *///from ww w. j a va 2 s .c o m private static Set<SnpEffect> getFilteredEffects(Multimap<String, SnpEffect> transcriptIdMap) { val result = new ImmutableSet.Builder<SnpEffect>(); for (val transcriptId : transcriptIdMap.keySet()) { val effectGroup = Lists.newArrayList(transcriptIdMap.get(transcriptId)); // order by importance Collections.sort(effectGroup, Collections.reverseOrder()); // limit by 1 result.add(effectGroup.get(0)); } return result.build(); }
From source file:org.sonar.plugins.pitest.Mutant.java
public static String toJSON(List<Mutant> mutants) { Multimap<Integer, String> mutantsByLine = ArrayListMultimap.create(); for (Mutant mutant : mutants) { mutantsByLine.put(mutant.getLineNumber(), mutant.toJSON()); }//from ww w .jav a 2 s .com StringBuilder builder = new StringBuilder(); builder.append("{"); boolean first = true; for (int line : mutantsByLine.keySet()) { if (!first) { builder.append(","); } first = false; builder.append("\""); builder.append(line); builder.append("\":["); builder.append(Joiner.on(",").join(mutantsByLine.get(line))); builder.append("]"); } builder.append("}"); return builder.toString(); }