List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:com.twitter.aurora.scheduler.http.Maintenance.java
@GET @Produces(MediaType.APPLICATION_JSON)// www . j a v a 2 s. co m public Response getHosts() { return storage.weaklyConsistentRead(new Work.Quiet<Response>() { @Override public Response apply(StoreProvider storeProvider) { Multimap<MaintenanceMode, String> hostsByMode = Multimaps.transformValues( Multimaps.index(storeProvider.getAttributeStore().getHostAttributes(), GET_MODE), HOST_NAME); Map<MaintenanceMode, Object> hosts = Maps.newHashMap(); hosts.put(DRAINED, ImmutableSet.copyOf(hostsByMode.get(DRAINED))); hosts.put(SCHEDULED, ImmutableSet.copyOf(hostsByMode.get(SCHEDULED))); hosts.put(DRAINING, getTasksByHosts(storeProvider, hostsByMode.get(DRAINING)).asMap()); return Response.ok(hosts).build(); } }); }
From source file:de.esukom.decoit.ifmapclient.iptables.PollResultChecker.java
/** * check if passed in filter-string-map contains the passed in property and if the related value * matches the passed in filter-value/* ww w . ja v a 2s . c om*/ * * @param filterStrings map containing filter-string * @param resultPropertyValue property to search for * @param resultFilterValue value of property that must be contained * * @return true, if passed in map contains the property and the value of that property matches * the passed in filter-value */ public boolean checkStringAttributeMatchesValue(Multimap<String, String> filterStrings, String resultPropertyValue, String resultFilterValue) { // get entry for attribute Object[] resultFilter = filterStrings.get(resultPropertyValue).toArray(); for (int i = 0; i < resultFilter.length; i++) { String currentFilter = (String) resultFilter[i]; if (resultPropertyValue.startsWith("!")) { if (!resultFilterValue.matches(currentFilter)) { return true; } } else { if (resultFilterValue.matches(currentFilter)) { return true; } } } return false; }
From source file:de.esukom.decoit.ifmapclient.iptables.PollResultChecker.java
/** * check if passed in filter-string-map contains the passed in property and if the related value * contains the passed in filter-value//from w ww . j a v a 2s .com * * @param filterStrings map containing filter-string * @param resultPropertyValue property to search for * @param resultFilterValue value of property that must be contained * * @return true, if passed in map contains the property and the value of that property contains * the passed in filter-value */ public boolean checkStringAttributeContainsValue(Multimap<String, String> filterStrings, String resultPropertyValue, String resultFilterValue) { // get entry for attribute Object[] resultFilter = filterStrings.get(resultPropertyValue).toArray(); for (int i = 0; i < resultFilter.length; i++) { String currentFilter = (String) resultFilter[i]; if (resultPropertyValue.startsWith("!")) { if (!resultFilterValue.contains(currentFilter)) { return true; } } else { if (resultFilterValue.contains(currentFilter)) { return true; } } } return false; }
From source file:org.summer.ss.core.dispatch.DispatchingSupport.java
protected void removeNonLocalMethods(final JvmGenericType type, Multimap<Pair<String, Integer>, JvmOperation> result) { List<Pair<String, Integer>> removeKeys = newArrayList(); for (Pair<String, Integer> signatureTuple : result.keySet()) { Collection<JvmOperation> collection = result.get(signatureTuple); if (!any(collection, new Predicate<JvmOperation>() { public boolean apply(JvmOperation input) { return input.getDeclaringType() == type; }//from w w w . java 2 s .c o m })) { removeKeys.add(signatureTuple); } } for (Pair<String, Integer> signatureTuple : removeKeys) { result.removeAll(signatureTuple); } }
From source file:co.cask.cdap.docgen.cli.GenerateCLIDocsTableCommand.java
@Override public void execute(Arguments arguments, PrintStream output) throws Exception { Multimap<String, Command> categorizedCommands = categorizeCommands(commands.get(), CommandCategory.GENERAL, Predicates.<Command>alwaysTrue()); for (CommandCategory category : CommandCategory.values()) { output.printf(" **%s**\n", category.getOriginalName()); List<Command> commandList = Lists.newArrayList(categorizedCommands.get(category.getName())); Collections.sort(commandList, new Comparator<Command>() { @Override/* ww w . ja va 2s .com*/ public int compare(Command command, Command command2) { return command.getPattern().compareTo(command2.getPattern()); } }); for (Command command : commandList) { output.printf(" ``%s``,\"%s\"\n", command.getPattern(), command.getDescription().replace("\"", "\"\"")); } } }
From source file:org.cinchapi.concourse.importer.AbstractImporter.java
/** * Import a single group of {@code data} (i.e. a line in a csv file) into * {@code concourse}.//from w w w . j a va2 s . c om * <p> * If {@code resolveKey} is specified, it is possible that the {@code data} * will be added to more than one existing record. It is guaranteed that an * attempt will be made to add the data to at least one (possibly) new * record. * </p> * * @param data * @param resolveKey * @return an {@link ImportResult} object that describes the records * created/affected from the import and whether any errors occurred. */ protected final ImportResult importGroup(Multimap<String, String> data, @Nullable String resolveKey) { // Determine import record(s) Set<Long> records = Sets.newHashSet(); for (String resolveValue : data.get(resolveKey)) { records = Sets.union(records, concourse.find(resolveKey, Operator.EQUALS, Convert.stringToJava(resolveValue))); records = Sets.newHashSet(records); // must make copy because // previous method returns // immutable view } if (records.isEmpty()) { records.add(concourse.create()); } // Iterate through the data and add it to Concourse ImportResult result = ImportResult.newImportResult(data, records); for (String key : data.keySet()) { for (String rawValue : data.get(key)) { if (!Strings.isNullOrEmpty(rawValue)) { // do not waste time // sending empty // values // over the wire Object convertedValue = Convert.stringToJava(rawValue); List<Object> values = Lists.newArrayList(); if (convertedValue instanceof ResolvableLink) { // Find all the records that resolve and create a // Link to those records. for (long record : concourse.find(((ResolvableLink) convertedValue).getKey(), Operator.EQUALS, ((ResolvableLink) convertedValue).getValue())) { values.add(Link.to(record)); } } else { values.add(convertedValue); } for (long record : records) { for (Object value : values) { if (!concourse.add(key, value, record)) { result.addError(MessageFormat.format("Could not import {0} AS {1} IN {2}", key, value, record)); } } } } } } return result; }
From source file:org.gradle.tooling.internal.consumer.converters.BuildInvocationsConverter.java
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); collectTasks(project, aggregatedTasks); List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new ConsumerProvidedTaskSelector().setName(selectorName).setTaskNames(selectorTasks) .setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)) .setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); }/*from w ww . j a v a 2 s .c o m*/ return selectors; }
From source file:com.android.tools.lint.checks.ManifestResourceDetector.java
private void reportIfFound(@NonNull XmlContext context, @NonNull String qualifiers, @NonNull String name, @NonNull ResourceType type, @Nullable Node secondary) { Multimap<ResourceType, Location> typeMap = mManifestLocations.get(name); if (typeMap != null) { Collection<Location> locations = typeMap.get(type); if (locations != null) { for (Location location : locations) { String message = getErrorMessage(qualifiers); if (secondary != null) { Location secondaryLocation = context.getLocation(secondary); secondaryLocation.setSecondary(location.getSecondary()); secondaryLocation.setMessage("This value will not be used"); location.setSecondary(secondaryLocation); }//from w ww . j ava 2 s.co m context.report(ISSUE, location, message); } } } }
From source file:org.summer.dsl.xbase.typesystem.override.ParameterizedResolvedFeatures.java
protected void computeAllFeatures(List<JvmFeature> unfiltered, Multimap<String, AbstractResolvedOperation> processedOperations, List<JvmFeature> result) { for (JvmFeature feature : unfiltered) { if (feature instanceof JvmOperation) { String simpleName = feature.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (parent.isOverridden((JvmOperation) feature, processedOperations.get(simpleName))) { continue; }/*from w w w. ja va 2 s . c om*/ } BottomResolvedOperation resolvedOperation = parent.createResolvedOperation((JvmOperation) feature, type); processedOperations.put(simpleName, resolvedOperation); result.add(feature); } else { result.add(feature); } } }
From source file:org.sonar.java.checks.MembersDifferOnlyByCapitalizationCheck.java
private void checkForIssue(Symbol symbol, IdentifierTree reportTree, Multimap<String, Symbol> membersByName) { String name = symbol.name();/*from w ww . ja v a 2 s . c o m*/ for (String knownMemberName : membersByName.keySet()) { if (name.equalsIgnoreCase(knownMemberName)) { Optional<Symbol> conflictingMember = membersByName.get(knownMemberName).stream() .filter(knownMemberSymbol -> !symbol.equals(knownMemberSymbol) && isValidIssueLocation(symbol, knownMemberSymbol) && isInvalidMember(symbol, knownMemberSymbol)) .findFirst(); if (conflictingMember.isPresent()) { Symbol conflictingSymbol = conflictingMember.get(); reportIssue(reportTree, "Rename " + getSymbolTypeName(symbol) + " \"" + name + "\" " + "to prevent any misunderstanding/clash with " + getSymbolTypeName(conflictingSymbol) + " \"" + knownMemberName + "\"" + getDefinitionPlace(symbol, conflictingSymbol) + "."); } } } }