List of usage examples for com.google.common.collect ListMultimap get
@Override List<V> get(@Nullable K key);
Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List , instead of the java.util.Collection specified in the Multimap interface.
From source file:fr.obeo.emf.specimen.DirectWriteSpecimenGenerator.java
protected List<EObject> resolveObjectsOfType(EClass eReferenceType, ListMultimap<EClass, String> indexByKind, Resource resource) {//from w w w . j a va 2 s . c o m List<EObject> possibleValues = new LinkedList<EObject>(); for (String uriFrag : indexByKind.get(eReferenceType)) { possibleValues.add(resource.getEObject(uriFrag)); } return possibleValues; }
From source file:org.gradle.plugin.use.internal.PluginDependenciesService.java
public List<PluginRequest> getRequests() { List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() { public PluginRequest transform(DependencySpecImpl original) { return new DefaultPluginRequest(original.id, original.version, original.lineNumber, scriptSource); }//w w w.ja va2 s.co m }); ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() { public PluginId transform(PluginRequest pluginRequest) { return pluginRequest.getId(); } }); // Check for duplicates for (PluginId key : groupedById.keySet()) { List<PluginRequest> pluginRequestsForId = groupedById.get(key); if (pluginRequestsForId.size() > 1) { PluginRequest first = pluginRequests.get(0); PluginRequest second = pluginRequests.get(1); InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber()); throw new LocationAwareException(exception, second.getScriptSource(), second.getLineNumber()); } } return pluginRequests; }
From source file:org.gradle.plugin.use.internal.PluginRequestCollector.java
public List<PluginRequest> getRequests() { List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() { public PluginRequest transform(DependencySpecImpl original) { return new DefaultPluginRequest(original.id, original.version, original.lineNumber, scriptSource); }// www . ja v a 2 s . c om }); ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() { public PluginId transform(PluginRequest pluginRequest) { return pluginRequest.getId(); } }); // Check for duplicates for (PluginId key : groupedById.keySet()) { List<PluginRequest> pluginRequestsForId = groupedById.get(key); if (pluginRequestsForId.size() > 1) { PluginRequest first = pluginRequests.get(0); PluginRequest second = pluginRequests.get(1); InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber()); throw new LocationAwareException(exception, second.getScriptDisplayName(), second.getLineNumber()); } } return pluginRequests; }
From source file:org.rf.ide.core.testdata.mapping.TwoModelReferencesLinker.java
@VisibleForTesting protected void validateThatTheSameTokensInView( final ListMultimap<RobotTokenType, RobotToken> oldViewAboutTokens, final ListMultimap<RobotTokenType, RobotToken> newViewAboutTokens) { final Set<RobotTokenType> newKeySet = newViewAboutTokens.keySet(); for (final RobotTokenType t : newKeySet) { final List<RobotToken> oldToks = new ArrayList<>(oldViewAboutTokens.get(t)); final List<RobotToken> newToks = newViewAboutTokens.get(t); int toksSize = -1; if (oldToks.size() == newToks.size()) { toksSize = oldToks.size();// w w w . ja v a 2s. c o m } else { removePreviousLineContinue(oldToks); final int oldNotEmpty = findTheFirstNotEmpty(oldToks); final int newNotEmpty = findTheFirstNotEmpty(newToks); if (oldNotEmpty == newNotEmpty) { toksSize = oldNotEmpty; } else { throw new DifferentOutputFile("Type " + t + " has not the same number of elements in outputs."); } } for (int i = 0; i < toksSize; i++) { final RobotToken rtOld = oldToks.get(i); final RobotToken rtNew = newToks.get(i); if (!rtOld.getText().equals(rtNew.getText())) { if (!isAcceptableContent(rtOld, rtNew)) { throw new DifferentOutputFile("Token type " + t + " with index " + i + " doesn't contain the same content as old. Expected " + rtOld.getText() + " got " + rtNew.getText()); } } } } }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.InstructionHighlighter.CReadsDescription.java
@Override public Collection<CSpecialInstruction> visit(final ReilFunction reilCode, final ListMultimap<IAddress, INaviInstruction> instructionMap) { final Collection<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>(); final Set<INaviInstruction> calls = new HashSet<INaviInstruction>(); for (final ReilBlock block : reilCode.getGraph()) { for (final ReilInstruction reilInstruction : block) { if (ReilHelpers.isFunctionCall(reilInstruction)) { calls.addAll(instructionMap.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress()))); }//from ww w . j a v a2 s.c om } } for (final ReilBlock block : reilCode.getGraph()) { for (final ReilInstruction reilInstruction : block) { if (reilInstruction.getMnemonic().equals(ReilHelpers.OPCODE_LDM)) { final List<INaviInstruction> firstInstructions = instructionMap .get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())); if (isAnyCall(firstInstructions, calls)) { continue; } final List<INaviInstruction> nativeInstructions = instructionMap .get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())); for (final INaviInstruction naviInstruction : nativeInstructions) { instructions.add(new CSpecialInstruction(this, naviInstruction)); } } } } return instructions; }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.InstructionHighlighter.CWritesDescription.java
@Override public Collection<CSpecialInstruction> visit(final ReilFunction reilCode, final ListMultimap<IAddress, INaviInstruction> instructionMap) { final Collection<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>(); final Set<INaviInstruction> calls = new HashSet<INaviInstruction>(); for (final ReilBlock block : reilCode.getGraph()) { for (final ReilInstruction reilInstruction : block) { if (ReilHelpers.isFunctionCall(reilInstruction)) { calls.addAll(instructionMap.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress()))); }// www .j a va 2s . c o m } } for (final ReilBlock block : reilCode.getGraph()) { for (final ReilInstruction reilInstruction : block) { if (reilInstruction.getMnemonic().equals(ReilHelpers.OPCODE_STM)) { final List<INaviInstruction> firstInstructions = instructionMap .get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())); if (isAnyCall(firstInstructions, calls)) { continue; } final List<INaviInstruction> nativeInstructions = instructionMap .get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())); for (final INaviInstruction naviInstruction : nativeInstructions) { instructions.add(new CSpecialInstruction(this, naviInstruction)); } } } } return instructions; }
From source file:de.ii.xtraplatform.feature.provider.pgis.SqlFeatureCreator.java
private Map<String, List<Integer>> computeCountsPerParentIndex( ListMultimap<String, List<Integer>> multiplicities) { Map<String, List<Integer>> countsPerParentIndex = new LinkedHashMap<>(); multiplicities.keySet().forEach(key -> { List<Integer> counts = new ArrayList<>(); int[] lastParent = { 0 }; multiplicities.get(key).forEach(list -> { List<Integer> indices = list.size() > 2 ? list.subList(list.size() - 2, list.size()) : list; boolean parent = list.size() > 1; // if parent instances have no children if (parent) { for (int i = indices.get(0) - lastParent[0]; i > 1; i--) { counts.add(0);//from w w w . ja va2 s. c o m } } if (parent && indices.get(0) > lastParent[0]) { counts.add(1); lastParent[0] = indices.get(0); } else if (!parent && counts.isEmpty()) { counts.add(1); } counts.set(counts.size() - 1, indices.get(indices.size() - 1)); }); countsPerParentIndex.put(key, counts); }); return countsPerParentIndex; }
From source file:com.google.enterprise.adaptor.MockHttpClient.java
@Override public HttpExchange postExchange(URL url, ListMultimap<String, String> parameters) { HttpExchange exchange = new ClientExchange(url, "POST"); if (parameters != null) { exchange.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" + POST_ENCODING); for (String name : parameters.keySet()) { for (String value : parameters.get(name)) { exchange.addParameter(name, value); }/*from w w w . j av a 2 s . c o m*/ } } return exchange; }
From source file:org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer.java
@Override public ServerName randomAssignment(HRegionInfo region, List<ServerName> servers) throws HBaseIOException { ListMultimap<String, HRegionInfo> regionMap = LinkedListMultimap.create(); ListMultimap<String, ServerName> serverMap = LinkedListMultimap.create(); generateGroupMaps(Lists.newArrayList(region), servers, regionMap, serverMap); List<ServerName> filteredServers = serverMap.get(regionMap.keySet().iterator().next()); return this.internalBalancer.randomAssignment(region, filteredServers); }
From source file:com.evanzeimet.queryinfo.jpa.attribute.DefaultEntityAnnotationsAttributeInfoResolver.java
protected List<String> generateNonUniqueAttributeNameMessages( ListMultimap<String, QueryInfoAttributeInfo> attributesMap) { List<String> nonUniqueFieldNameTexts = new ArrayList<>(); Iterator<String> attributeNames = attributesMap.keySet().iterator(); while (attributeNames.hasNext()) { String attributeName = attributeNames.next(); List<QueryInfoAttributeInfo> attributes = attributesMap.get(attributeName); int attributeCount = attributes.size(); if (attributeCount > 1) { List<String> jpaAttributeNames = new ArrayList<>(attributes.size()); for (QueryInfoAttributeInfo attribute : attributes) { String jpaAttributeName = attribute.getJpaAttributeName(); jpaAttributeNames.add(jpaAttributeName); }/*w w w . ja va 2s . c om*/ String jpaAttributeNamesTest = StringUtils.join(jpaAttributeNames, ", "); String nonUniqueFieldNameText = String.format("Found [%s] field infos for name [%s]: %s", attributeCount, attributeName, jpaAttributeNamesTest); nonUniqueFieldNameTexts.add(nonUniqueFieldNameText); } } return nonUniqueFieldNameTexts; }