List of usage examples for com.google.common.collect SetMultimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:org.eclipse.osee.orcs.db.internal.sql.ObjectField.java
public static Set<ObjectField> getFieldsFor(Family family) { if (FAMILY_TO_FIELDS == null) { SetMultimap<Family, ObjectField> familyToFields = newSetMultimap(); for (ObjectField field : ObjectField.values()) { familyToFields.put(field.getFamily(), field); }//from ww w . j a v a2s. co m ObjectField.FAMILY_TO_FIELDS = familyToFields; } return FAMILY_TO_FIELDS.get(family); }
From source file:de.bund.bfr.knime.gis.views.regiontoregionvisualizer.RegionToRegionUtils.java
public static Set<String> getSelectedGisEdgeIds(Set<Edge<RegionNode>> gisEdges, Set<Edge<GraphNode>> graphSelectedEdges, boolean joinEdges) { if (!joinEdges) { return CanvasUtils.getElementIds(graphSelectedEdges); }/*ww w .j a v a2 s . com*/ SetMultimap<Pair<String, String>, String> gisEdgesByRegion = LinkedHashMultimap.create(); for (Edge<RegionNode> gisEdge : gisEdges) { String fromRegion = gisEdge.getFrom().getId(); String toRegion = gisEdge.getTo().getId(); gisEdgesByRegion.put(new Pair<>(fromRegion, toRegion), gisEdge.getId()); } Set<String> selectedGisEdgeIds = new LinkedHashSet<>(); for (Edge<GraphNode> graphEdge : graphSelectedEdges) { String fromRegion = graphEdge.getFrom().getRegion(); String toRegion = graphEdge.getTo().getRegion(); selectedGisEdgeIds.addAll(gisEdgesByRegion.get(new Pair<>(fromRegion, toRegion))); } return selectedGisEdgeIds; }
From source file:prm4j.spec.finite.FiniteParametricProperty.java
private static <A, B> Multimap<B, A> reverseSetMultimap(Multimap<A, B> multiMap) { SetMultimap<B, A> reversedSetMultimap = HashMultimap.create(); for (A a : multiMap.keySet()) { for (B b : multiMap.get(a)) { reversedSetMultimap.put(b, a); }//w w w. ja va2 s . c o m } return reversedSetMultimap; }
From source file:de.bund.bfr.knime.gis.views.regiontoregionvisualizer.RegionToRegionUtils.java
public static Set<String> getSelectedGraphEdgeIds(Set<Edge<GraphNode>> graphEdges, Set<Edge<RegionNode>> gisSelectedEdges, boolean joinEdges) { if (!joinEdges) { return CanvasUtils.getElementIds(gisSelectedEdges); }//from w w w .j a v a 2 s. co m SetMultimap<Pair<String, String>, String> graphEdgesByRegion = LinkedHashMultimap.create(); for (Edge<GraphNode> graphEdge : graphEdges) { String fromRegion = graphEdge.getFrom().getRegion(); String toRegion = graphEdge.getTo().getRegion(); graphEdgesByRegion.put(new Pair<>(fromRegion, toRegion), graphEdge.getId()); } Set<String> selectedGraphEdgeIds = new LinkedHashSet<>(); for (Edge<RegionNode> gisEdge : gisSelectedEdges) { String fromRegion = gisEdge.getFrom().getId(); String toRegion = gisEdge.getTo().getId(); selectedGraphEdgeIds.addAll(graphEdgesByRegion.get(new Pair<>(fromRegion, toRegion))); } return selectedGraphEdgeIds; }
From source file:com.palantir.atlasdb.keyvalue.rdbms.utils.AtlasSqlUtils.java
public static <K, V> SetMultimap<K, V> listToSetMultimap(List<Pair<K, V>> list) { SetMultimap<K, V> result = HashMultimap.create(); for (Pair<K, V> p : list) { Preconditions.checkArgument(!result.containsEntry(p.lhSide, p.rhSide)); result.put(p.lhSide, p.rhSide); }/*from w ww .j a va 2 s .c om*/ return result; }
From source file:org.eclipse.osee.orcs.db.internal.sql.ObjectField.java
public static Set<ObjectField> getRequiredFieldsFor(Family family) { if (FAMILY_TO_REQUIRED_FIELDS == null) { SetMultimap<Family, ObjectField> familyToFields = newSetMultimap(); for (ObjectField field : ObjectField.values()) { if (field.isRequired()) { familyToFields.put(field.getFamily(), field); }//from w w w . j a v a2 s.c om } ObjectField.FAMILY_TO_REQUIRED_FIELDS = familyToFields; } return FAMILY_TO_REQUIRED_FIELDS.get(family); }
From source file:com.google.devtools.cyclefinder.ReferenceGraph.java
private static SetMultimap<String, Edge> makeSubgraph(SetMultimap<String, Edge> graph, Collection<String> vertices) { SetMultimap<String, Edge> subgraph = HashMultimap.create(); for (String type : vertices) { for (Edge e : graph.get(type)) { if (vertices.contains(e.getTarget().getKey())) { subgraph.put(type, e); }/* ww w.j av a2 s.c om*/ } } return subgraph; }
From source file:de.bund.bfr.knime.openkrise.common.DeliveryUtils.java
private static void checkAmounts(Map<String, Delivery> deliveries, SetMultimap<String, String> warnings) { SetMultimap<String, Delivery> deliveriesByLot = LinkedHashMultimap.create(); for (Delivery d : deliveries.values()) { deliveriesByLot.put(d.getLotNumber(), d); }/*from w ww . ja v a 2 s . c o m*/ for (Map.Entry<String, Set<Delivery>> lot : Multimaps.asMap(deliveriesByLot).entrySet()) { Set<String> ingredients = new LinkedHashSet<>(); Double kgOut = 0.0; Double amountOut = 0.0; String unitOut = null; for (Delivery d : lot.getValue()) { ingredients = d.getAllPreviousIds(); if (kgOut != null) { if (d.getAmountInKg() != null) { kgOut += d.getAmountInKg(); } else { kgOut = null; } } if (amountOut != null) { if (d.getAmount() != null && d.getUnit() != null && (unitOut == null || unitOut.equals(d.getUnit()))) { amountOut += d.getAmount(); unitOut = d.getUnit(); } else { amountOut = null; } } } if (ingredients.isEmpty()) { continue; } Double kgIn = 0.0; Double amountIn = 0.0; String unitIn = null; for (String prev : ingredients) { Delivery d = deliveries.get(prev); if (kgIn != null) { if (d.getAmountInKg() != null) { kgIn += d.getAmountInKg(); } else { kgIn = null; } } if (amountIn != null) { if (d.getAmount() != null && d.getUnit() != null && (unitIn == null || unitIn.equals(d.getUnit()))) { amountIn += d.getAmount(); unitIn = d.getUnit(); } else { amountIn = null; } } } if (amountIn != null && unitIn != null && amountOut != null && unitOut != null && unitIn.equals(unitOut) && areTooDifferent(amountIn, amountOut)) { warnings.put(AMOUNTS_INCORRECT, "Lot=" + lot.getKey() + ": In=" + amountIn + " vs. Out=" + amountOut + " (" + unitOut + ")"); } else if (kgIn != null && kgOut != null && areTooDifferent(kgIn, kgOut)) { warnings.put(AMOUNTS_INCORRECT, "Lot=" + lot.getKey() + ": In=" + kgIn + "kg vs. Out=" + kgOut + "kg"); } } }
From source file:com.exentes.maven.versions.VersionMojoUtils.java
public static SetMultimap<Artifact, MavenProject> allSnapshotProjectArtifacts(MavenSession session) { SetMultimap<Artifact, MavenProject> allSnapshotProjectArtifacts = HashMultimap.create(); for (MavenProject project : session.getProjects()) { for (Artifact artifact : difference(newHashSet(filterSnapshots(project.getDependencyArtifacts())), newHashSet(transform(session.getProjects(), toProjectArtifactFunction)))) { allSnapshotProjectArtifacts.put(artifact, project); }/*from w w w .j a v a2s .c om*/ } return allSnapshotProjectArtifacts; }
From source file:org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirementHelper.java
/** * Gets a map in which the keys are the types of different requirements and * the values represents a list of requirement values linked to that type. * We only take values with the same priority level as the argument. * * @param providers/* ww w.j av a 2 s . com*/ * The set of analysis requirement provider * @param level * The priority level of the values to be returned * @return A map with the values keyed by type */ public static SetMultimap<String, String> getRequirementValuesMap( Iterable<IAnalysisRequirementProvider> providers, ValuePriorityLevel level) { SetMultimap<String, String> valuesByType = HashMultimap.create(); for (IAnalysisRequirementProvider provider : providers) { for (TmfAnalysisRequirement requirement : provider.getAnalysisRequirements()) { /* Since it's a set, there will be no duplicate */ for (String value : requirement.getValues()) { if (requirement.getValueLevel(value) == level) { valuesByType.put(requirement.getType(), value); } } } } return valuesByType; }