List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:fr.jcgay.maven.plugin.buildplan.display.AbstractTableDescriptor.java
protected static Map<TableColumn, Integer> findMaxSize(Collection<MojoExecution> executions, TableColumn... columns) { Map<TableColumn, Integer> result = new HashMap<TableColumn, Integer>(); Multimap<TableColumn, Integer> count = ArrayListMultimap.create(); for (MojoExecution execution : executions) { for (TableColumn column : columns) { switch (column) { case ARTIFACT_ID: count.put(column, safeLength(execution.getArtifactId())); break; case EXECUTION_ID: count.put(column, safeLength(execution.getExecutionId())); break; case GOAL: count.put(column, safeLength(execution.getGoal())); break; case PHASE: MojoDescriptor mojoDescriptor = execution.getMojoDescriptor(); if (mojoDescriptor != null && mojoDescriptor.getPhase() != null) { count.put(column, safeLength(mojoDescriptor.getPhase())); } else { count.put(column, safeLength(execution.getLifecyclePhase())); }/*from ww w . j a va2s .c o m*/ } } } for (TableColumn column : TableColumn.values()) { count.put(column, column.title().length()); } for (TableColumn key : count.keySet()) { result.put(key, Collections.max(count.get(key))); } return result; }
From source file:org.eclipse.sirius.business.internal.session.SessionEventBrokerImpl.java
private void collectListeners(Notification msg, EObject changedObj, Multimap<EObject, ModelChangeTrigger> map, Multimap<ModelChangeTrigger, Notification> result) { Collection<ModelChangeTrigger> listeners = map.get(changedObj); if (listeners != null) { for (ModelChangeTrigger preCommitListener : listeners) { result.put(preCommitListener, msg); }/*from w w w . java 2s .c om*/ } }
From source file:eu.interedition.collatex.dekker.matrix.IslandConflictResolver.java
private void resolveConflictsBySelectingPreferredIslands(MatchTableSelection selection, Multimap<IslandCompetition, Island> islandConflictMap) { // First select competing islands that are on the ideal line Multimap<Double, Island> distanceMap1 = makeDistanceMap( islandConflictMap.get(IslandCompetition.CompetingIslandAndOnIdealIine)); LOG.fine("addBestOfCompeting with competingIslandsOnIdealLine"); addBestOfCompeting(selection, distanceMap1); // Second select other competing islands Multimap<Double, Island> distanceMap2 = makeDistanceMap( islandConflictMap.get(IslandCompetition.CompetingIsland)); LOG.fine("addBestOfCompeting with otherCompetingIslands"); addBestOfCompeting(selection, distanceMap2); // Third select non competing islands LOG.fine("add non competing islands"); for (Island i : islandConflictMap.get(IslandCompetition.NonCompetingIsland)) { selection.addIsland(i);/* ww w. jav a2 s. c om*/ } }
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); }/*from www.ja v a 2 s. c om*/ 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:org.codice.ddf.transformer.xml.streaming.lib.SaxEventToXmlElementConverter.java
private boolean checkNamespaceAdded(String uri, Map<String, String> scopedNamespaces) { Multimap<String, String> peek = scopeOfNamespacesAdded.peek(); return peek != null && peek.containsKey(uri) && peek.get(uri).contains(scopedNamespaces.get(uri)); }
From source file:org.jclouds.openstack.nova.v1_1.compute.NovaComputeService.java
@Override protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) { Multimap<String, String> zoneToZoneAndGroupNames = orphanedGroupsByZoneId.apply(deadNodes); for (String zoneId : zoneToZoneAndGroupNames.keySet()) { cleanOrphanedGroupsInZone(ImmutableSet.copyOf(zoneToZoneAndGroupNames.get(zoneId)), zoneId); }/*ww w . jav a 2s . c om*/ }
From source file:eu.trentorise.opendata.disiclient.UrlMapper.java
/** * Extracts from multimap the first item correspond to {@code property} * * @throws IllegalArgumentException if there is not exactly one { * @property}//from w ww . jav a 2s. c om */ private String getFirst(Multimap<String, String> m, String property) { int sz = m.get(property).size(); if (sz != 1) { throw new IllegalArgumentException("Expected one " + property + ", found " + sz + " instead."); } else { return Iterables.getFirst(m.get(property), ""); } }
From source file:org.eclipse.emf.compare.diagram.sirius.internal.SiriusDiffPostProcessor.java
/** * Add diff requires for every change related to the semantic target. * //from w w w. j ava 2 s. co m * @param diffsByValue * {@link ReferenceChange} differences indexed by value. * @param referenceChange * a given {@link ReferenceChange}. * @param semanticTarget * the semantic target. */ private void addRequiresToDecoratedElement(Multimap<EObject, ReferenceChange> diffsByValue, ReferenceChange referenceChange, EObject semanticTarget) { for (Diff valueDiff : diffsByValue.get(semanticTarget)) { if (referenceChange.getKind() == DifferenceKind.ADD) { if (valueDiff.getKind() == DifferenceKind.ADD && fromSide(referenceChange.getSource()).apply(valueDiff)) { referenceChange.getRequires().add(valueDiff); } } else if (referenceChange.getKind() == DifferenceKind.DELETE) { if (valueDiff.getKind() == DifferenceKind.DELETE && fromSide(referenceChange.getSource()).apply(valueDiff)) { referenceChange.getRequires().add(valueDiff); } } } }
From source file:org.opentestsystem.shared.security.service.RoleSpecificPermissionsService.java
private Map<String, RoleToPermissionMapping> getRoleMapping() { if (roleMapping == null) { Map<String, RoleToPermissionMapping> map = new HashMap<String, RoleToPermissionMapping>(); Multimap<String, SbacPermission> resolvedRoles = permissionResolver.getRoleBindings(componentName); for (String sbacRoleName : resolvedRoles.keySet()) { RoleToPermissionMapping mapping = new RoleToPermissionMapping(sbacRoleName, resolvedRoles.get(sbacRoleName), true); map.put(sbacRoleName, mapping); }// ww w . jav a 2 s. c o m roleMapping = map; } return roleMapping; }
From source file:org.smartdeveloperhub.vocabulary.util.VocabularyHelper.java
Set<String> prefixes() { final Namespace namespace = Namespace.create(this.module.ontology()); final Multimap<String, String> prefixes = namespacePrefixes(); final SortedSet<String> nsPrefixes = Sets.newTreeSet(); for (final String ns : namespace.variants()) { final Collection<String> collection = prefixes.get(ns); if (collection != null) { nsPrefixes.addAll(collection); }/*from w w w .j av a 2s. c o m*/ } return nsPrefixes; }