List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:org.mqnaas.api.providers.MultiMapSerializationProvider.java
@Override public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { StringBuilder sb = new StringBuilder(); Multimap<Class<?>, IIdentifiable> multimap = (Multimap<Class<?>, IIdentifiable>) t; sb.append("<services>"); for (Class<?> capability : multimap.keySet()) { sb.append("<capability name=\"").append(capability.getName()).append("\">"); for (IIdentifiable identifiable : multimap.get(capability)) { sb.append("<service>"); sb.append(identifiable.getId()); sb.append("</service>"); }//from w ww . j a va 2 s.c o m sb.append("</capability>"); } sb.append("</services>"); entityStream.write(sb.toString().getBytes()); }
From source file:com.squareup.osstrich.JavadocPublisher.java
private void writeIndexFiles(String groupId, Multimap<String, Artifact> artifacts) throws IOException { for (String majorVersion : artifacts.keySet()) { StringBuilder html = new StringBuilder(); html.append("<!DOCTYPE html>\n<html><head><title>").append(groupId) .append("</title></head>\n<body>\n<h1>").append(groupId).append("</h1>\n<ul>\n"); for (Artifact artifact : artifacts.get(majorVersion)) { html.append("<li><a href=\"").append(artifact.artifactId).append("\">").append(artifact.artifactId) .append("</li>\n"); }/*from w ww . j a va 2 s.c o m*/ html.append("</ul>\n</body>\n</html>"); File indexHtml = new File(directory + "/" + majorVersion + "/index.html"); Files.write(html, indexHtml, UTF_8); gitAdd(indexHtml); } }
From source file:org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy.java
@Override protected Iterable<? extends RunningInstance> pollRunningInstancesByRegionsAndIds( final Multimap<String, String> idsByRegions) { Iterable<? extends AWSRunningInstance> spots = filter( transform(concat(transform(idsByRegions.keySet(), spotInstancesByIdInRegion(idsByRegions))), spotConverter),/* w w w .j a va 2s . c om*/ notNull()); Iterable<? extends RunningInstance> superInsts = super.pollRunningInstancesByRegionsAndIds(idsByRegions); return concat(superInsts, spots); }
From source file:com.google.devtools.build.lib.query2.AbstractEdgeVisitor.java
protected Iterable<Target> processResultsAndReturnTargets(Iterable<SkyKey> keysToUseForResult, Callback<Target> callback) throws QueryException, InterruptedException { Multimap<SkyKey, SkyKey> packageKeyToTargetKeyMap = env.makePackageKeyToTargetKeyMap(keysToUseForResult); Set<PackageIdentifier> pkgIdsNeededForResult = packageKeyToTargetKeyMap.keySet().stream() .map(SkyQueryEnvironment.PACKAGE_SKYKEY_TO_PACKAGE_IDENTIFIER).collect(toImmutableSet()); packageSemaphore.acquireAll(pkgIdsNeededForResult); Iterable<Target> targets; try {/*from ww w . j a v a2s. c om*/ targets = env.makeTargetsFromPackageKeyToTargetKeyMap(packageKeyToTargetKeyMap).values(); callback.process(targets); } finally { packageSemaphore.releaseAll(pkgIdsNeededForResult); } return targets; }
From source file:io.fd.maintainer.plugin.util.CommonTasks.java
static String formatReviewerInfo(final Set<ComponentReviewInfo> reviewInfoSet) { final Multimap<String, String> componentToAffectedFileIndex = LinkedListMultimap.create(); final Set<ComponentReviewInfo> componentBoundReviewInfoSet = reviewInfoSet.stream() .filter(reviewInfo -> reviewInfo.getState() == COMPONENT_FOUND).collect(Collectors.toSet()); componentBoundReviewInfoSet.forEach(reviewInfo -> componentToAffectedFileIndex .put(reviewInfo.getComponentName(), reviewInfo.getAffectedFile())); final Map<String, Set<Maintainer>> componentToMaintainers = new HashMap<>(); componentBoundReviewInfoSet.forEach(reviewInfo -> { if (!componentToMaintainers.containsKey(reviewInfo.getComponentName())) { componentToMaintainers.put(reviewInfo.getComponentName(), reviewInfo.getComponentMaintainers()); }// w w w. j a v a 2s. co m }); final List<ComponentReviewInfo> componentNotFoundReviewInfos = reviewInfoSet.stream() .filter(reviewInfo -> reviewInfo.getState() == COMPONENT_NOT_FOUND).collect(Collectors.toList()); final String messageComponentsFound = componentToAffectedFileIndex.keySet().stream() .map(key -> format("Component %s%s%s" + "Maintainers :%s%s%s" + "Affected files :%s%s%s", key, LINE_SEPARATOR, LINE_SEPARATOR, LINE_SEPARATOR, formatMaintainers(componentToMaintainers.get(key)), LINE_SEPARATOR, LINE_SEPARATOR, formatFiles(componentToAffectedFileIndex.get(key)), LINE_SEPARATOR)) .collect(Collectors.joining(LINE_SEPARATOR)); final String messageComponentsNotFound = format("No component found for following files%s%s", LINE_SEPARATOR, formatFilesWithNoComponent(componentNotFoundReviewInfos)); if (nonNull(messageComponentsNotFound)) { return messageComponentsFound.concat(LINE_SEPARATOR).concat(messageComponentsNotFound); } else { return messageComponentsFound; } }
From source file:org.apache.storm.streams.processors.ForwardingProcessorContext.java
public ForwardingProcessorContext(ProcessorNode processorNode, Multimap<String, ProcessorNode> streamToChildren) { this.processorNode = processorNode; this.streamToChildren = streamToChildren; this.streams = streamToChildren.keySet(); }
From source file:org.artifactory.search.deployable.VersionUnitSearcher.java
private Set<VersionUnitSearchResult> getVersionUnitResults( Multimap<ModuleInfo, RepoPath> moduleInfoToRepoPaths) { Set<VersionUnitSearchResult> searchResults = Sets.newHashSet(); for (ModuleInfo moduleInfo : moduleInfoToRepoPaths.keySet()) { searchResults.add(new VersionUnitSearchResult( new VersionUnit(moduleInfo, Sets.newHashSet(moduleInfoToRepoPaths.get(moduleInfo))))); }//ww w . jav a2s .co m return searchResults; }
From source file:com.ibm.common.activitystreams.internal.MultimapAdapter.java
/** * Method serialize./* w ww .ja v a 2 s .com*/ * @param src Multimap * @param typeOfSrc Type * @param context JsonSerializationContext * @return JsonElement */ public JsonElement serialize(Multimap src, Type typeOfSrc, JsonSerializationContext context) { JsonObject obj = new JsonObject(); for (Object key : src.keySet()) { Iterable<Object> vals = src.get(key); if (size(vals) == 1) { Object f = getFirst(vals, null); if (f != null) obj.add(key.toString(), context.serialize(f, f.getClass())); } else { obj.add(key.toString(), context.serialize(vals, Iterable.class)); } } return obj; }
From source file:org.tensorics.core.tensor.operations.OngoingMapOut.java
public <C1> Tensor<Map<C1, V>> inDirectionOf(Class<? extends C1> dimension) { Builder<Map<C1, V>> tensorBuilder = ImmutableTensor .builder(OngoingMapOut.dimensionsExcept(tensor.shape().dimensionSet(), dimension)); tensorBuilder.context(tensor.context()); // XXX IS this correct? Multimap<Set<?>, Entry<Position, V>> fullEntries = groupBy(TensorInternals.mapFrom(tensor).entrySet(), dimension);/* ww w. java2 s . c om*/ for (Set<?> key : fullEntries.keySet()) { Map<C1, V> values = mapByDimension(fullEntries.get(key), dimension); tensorBuilder.put(Position.of(key), values); } return tensorBuilder.build(); }
From source file:org.apache.apex.malhar.lib.window.accumulation.PojoFullOuterJoin.java
@Override public void addNonMatchingRightStream(Multimap<List<Object>, Object> rightStream, Map<String, PojoUtils.Getter> rightGettersStream, List<Object> result) { for (Object key : rightStream.keySet()) { if (outputToInputMap == null) { addNonMatchingResult(rightStream.get((List) key), rightGettersStream, result); } else {/*w w w .j a v a 2 s. c o m*/ for (Object obj : rightStream.get((List) key)) { Object o; try { o = outClass.newInstance(); } catch (Throwable e) { throw Throwables.propagate(e); } for (Map.Entry<String, KeyValPair<STREAM, String>> entry : outputToInputMap.entrySet()) { if (entry.getValue().getKey() == STREAM.RIGHT) { setters.get(entry.getKey()).set(o, rightGettersStream.get(entry.getValue().getValue()).get(obj)); } } result.add(o); } } } }