List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:blue.lapis.pore.converter.wrapper.CachedWrapperConverter.java
@SuppressWarnings("unchecked") private <S, P extends B> Converter<S, P> build( Multimap<Class<? extends B>, Map.Entry<Class<? extends B>, Class<?>>> childrenRegistry, Class<S> sponge, Class<P> pore) {/*from ww w .j a va 2 s . co m*/ // Create children converters Collection<Map.Entry<Class<? extends B>, Class<?>>> children = childrenRegistry.get(pore); ImmutableMap.Builder<Class<? extends S>, Converter<? extends S, ? extends P>> converterRegistry = ImmutableMap .builder(); for (Map.Entry<Class<? extends B>, Class<?>> child : children) { Class<? extends S> childSponge = (Class<? extends S>) child.getValue(); converterRegistry.put(childSponge, build(childrenRegistry, childSponge, (Class<? extends P>) child.getKey())); } return new Converter<S, P>(sponge, pore, converterRegistry.build()); }
From source file:org.artifactory.ui.rest.service.builds.buildsinfo.tabs.licenses.ChangeBuildLicenseService.java
/** * Get all licenses that are currently on the models for a specific id and repo path * * @param id The id of the model//from w w w . j av a2s.c o m * @param repoPath The repo path of the model * @return The current values (licenses) for a specific id and repo path. */ private Map<String, LicenseInfo> getCurrentValues(String id, RepoPath repoPath, Multimap<RepoPath, ModuleLicenseModel> LicenseMap) { List<LicenseInfo> licenseInfos = Lists.newArrayList(); Map<String, LicenseInfo> licenseMap = new HashMap<>(); Iterable<ModuleLicenseModel> modelsWithSameId = Iterables.filter(LicenseMap.get(repoPath), new SameIdPredicate(id)); for (ModuleLicenseModel moduleLicenseModel : modelsWithSameId) { LicenseInfo licenseInfo = moduleLicenseModel.getLicense(); if (licenseInfo.isValidLicense()) { licenseInfos.add(licenseInfo); licenseMap.put(licenseInfo.getName(), licenseInfo); } } return licenseMap; }
From source file:fr.putnami.pwt.doc.client.page.sample.decorator.SampleDecorator.java
protected void addSources(Multimap<String, String> sources) { Panel panelToOpen = null;//from ww w . j av a 2s . c o m String sourceToOpen = null; this.sourceAccordion.clear(); for (String panelName : sources.keySet()) { List sourceList = new List(); sourceList.setType(Type.LIST); for (String source : sources.get(panelName)) { if (sourceToOpen == null) { sourceToOpen = source; } sourceList.add(new SourceItem(source)); } Panel sourcePanel = new Panel(); if (panelToOpen == null) { panelToOpen = sourcePanel; } sourcePanel.add(new Header(panelName)); sourcePanel.add(sourceList); this.sourceAccordion.add(sourcePanel); } this.requestFile(sourceToOpen); final Panel toOpen = panelToOpen; Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { toOpen.setCollapse(false); } }); }
From source file:com.synflow.core.transformations.impl.StoreOnceTransformation.java
private Map<Var, Var> removeDuplicates(Multimap<Var, Var> multiMap) { Map<Var, Var> localMap = new LinkedHashMap<Var, Var>(); for (Var global : multiMap.keySet()) { Iterator<Var> it = multiMap.get(global).iterator(); if (!it.hasNext()) { continue; }//from w w w. j av a 2s .c o m Var local = it.next(); while (it.hasNext()) { Var duplicate = it.next(); for (Def def : new ArrayList<>(duplicate.getDefs())) { def.setVariable(local); } for (Use use : new ArrayList<>(duplicate.getUses())) { use.setVariable(local); } // just remove from container EcoreUtil.remove(duplicate); } localMap.put(global, local); } return localMap; }
From source file:it.sayservice.platform.smartplanner.otp.schedule.TransitTimes.java
public void buildStopIds() { BucketSet mergedBs = new BucketSet(); Multimap<String, TripTimes> map = ArrayListMultimap.create(); for (TripTimes tt : times) { map.put(tt.getRecurrence(), tt); }/*from w w w. jav a 2s . c om*/ List<BucketSet> bss = new ArrayList<BucketSet>(); BucketSet bs; for (String key : map.keySet()) { bs = new BucketSet(); List<TripTimes> ttl = (List<TripTimes>) map.get(key); Collections.sort(ttl, new Comparator<TripTimes>() { @Override public int compare(TripTimes o1, TripTimes o2) { return o2.getTripTimes().size() - o1.getTripTimes().size(); } }); for (TripTimes tt : ttl) { List<Bucket> buckets = new ArrayList<Bucket>(); for (TripTimeEntry sch : tt.getTripTimes()) { Bucket b = sch.toBucket(); buckets.add(b); } bs.merge(buckets); } bss.add(bs); } for (BucketSet bs0 : bss) { mergedBs.merge(bs0.getBuckets()); } stopIds = mergedBs.getIds(); }
From source file:org.robotframework.ide.eclipse.main.plugin.search.participants.TargetedSearch.java
public final void run(final IProgressMonitor monitor, final Multimap<IProject, LibrarySpecification> libraries, final Set<IFile> files) throws OperationCanceledException { monitor.beginTask("Searching for '" + searchPattern.getPattern() + "'", libraries.values().size() + files.size()); for (final IProject project : libraries.keySet()) { for (final LibrarySpecification librarySpecification : libraries.get(project)) { if (monitor.isCanceled()) { throw new OperationCanceledException(); }// ww w. j a va2 s . c om monitor.subTask("locating matches in " + librarySpecification.getName() + " library used by '" + project.getName() + "' project"); locateMatchesInLibrarySpecification(project, librarySpecification); for (final KeywordSpecification keywordSpecification : librarySpecification.getKeywords()) { locateMatchesInKeywordSpecification(project, librarySpecification, keywordSpecification); } monitor.worked(1); } } for (final IFile file : files) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } locateMatchesInRobotFile(model.createSuiteFile(file)); monitor.worked(1); } }
From source file:com.b2international.snowowl.datastore.index.ImmutableIndexCommitChangeSet.java
/** * Apply this {@link ImmutableIndexCommitChangeSet} on the given {@link RevisionWriter index transaction}. * //from ww w . jav a 2 s .c om * @param index * @throws IOException */ @Override public void apply(RevisionWriter index) throws IOException { for (final Class<?> type : rawDeletions.keySet()) { final Map<Class<?>, Set<String>> map = Collections.<Class<?>, Set<String>>singletonMap(type, Sets.newHashSet(rawDeletions.get(type))); index.writer().removeAll(map); } for (Entry<String, Object> doc : rawMappings.entrySet()) { if (!rawDeletions.containsValue(doc.getKey())) { index.writer().put(doc.getKey(), doc.getValue()); } } final Multimap<Class<? extends Revision>, Long> copiedRevision = ImmutableMultimap .copyOf(revisionDeletions); for (Class<? extends Revision> type : copiedRevision.keySet()) { index.remove(type, copiedRevision.get(type)); } for (Entry<Long, Revision> doc : revisionMappings.entrySet()) { if (!revisionDeletions.containsValue(doc.getKey())) { index.put(doc.getKey(), doc.getValue()); } } }
From source file:com.griddynamics.jagger.master.AbstractDistributor.java
@Override public Service distribute(final ExecutorService executor, final String sessionId, final String taskId, final Multimap<NodeType, NodeId> availableNodes, final Coordinator coordinator, final T task, final DistributionListener listener) { Set<Qualifier<?>> qualifiers = getQualifiers(); final Map<NodeId, RemoteExecutor> remotes = Maps.newHashMap(); for (NodeId nodeId : availableNodes.get(NodeType.KERNEL)) { boolean canRunTheCommand = coordinator.canExecuteCommands(nodeId, qualifiers); if (canRunTheCommand) { remotes.put(nodeId, coordinator.getExecutor(nodeId)); } else {//from w w w. java 2 s .c om log.debug("command type {} are not supported by kernel {}", qualifiers, nodeId); } } if (remotes.isEmpty()) { throw new NodeNotFound("Nodes not found to distribute the task"); } final Service service = performDistribution(executor, sessionId, taskId, task, remotes, availableNodes, coordinator); return new ForwardingService() { @Override public ListenableFuture<State> start() { ListenableFuture<Nothing> runListener = Futures .makeListenable(executor.submit(new Callable<Nothing>() { @Override public Nothing call() { listener.onDistributionStarted(sessionId, taskId, task, remotes.keySet()); return Nothing.INSTANCE; } })); return Futures.chain(runListener, new Function<Nothing, ListenableFuture<State>>() { @Override public ListenableFuture<State> apply(Nothing input) { return doStart(); } }); } private ListenableFuture<State> doStart() { return super.start(); } @Override protected Service delegate() { return service; } @Override public ListenableFuture<State> stop() { ListenableFuture<State> stop = super.stop(); return Futures.chain(stop, new Function<State, ListenableFuture<State>>() { @Override public ListenableFuture<State> apply(final State input) { final SettableFuture<State> result = SettableFuture.create(); executor.execute(new Runnable() { @Override public void run() { try { listener.onTaskDistributionCompleted(sessionId, taskId, task); } finally { result.set(input); } } }); return result; } }); } }; }
From source file:org.sourcepit.maven.dependency.model.aether.DependencyModelBuildingGraphTransformer.java
private void handleArtifacts(final Multimap<ArtifactKey, DependencyNode> keyToNodes) { for (final ArtifactKey artifactKey : keyToNodes.keySet()) { final Collection<DependencyNode> nodes = keyToNodes.get(artifactKey); final DependencyNode node = nodes.iterator().next(); final Artifact artifact = node.getDependency().getArtifact(); final boolean referenced = referencedArtifacts.contains(artifactKey); handleArtifacts(keyToNodes, nodes, artifact, referenced); }//from w w w . j a v a 2 s . co m }
From source file:eu.tomylobo.routes.config.Config.java
public void save() { Multimap<String, Multimap<String, String>> sections = LinkedListMultimap.create(); for (Entry entry : entries) { final String sectionName = entry.sectionName; final Collection<Multimap<String, String>> matchingSections = sections.get(sectionName); final Multimap<String, String> section; if (matchingSections.isEmpty()) { sections.put(sectionName, section = LinkedListMultimap.create()); } else {//from w w w .ja v a 2 s.c o m section = matchingSections.iterator().next(); } final String key = entry.key; final Field field = entry.field; final Object value; try { value = field.get(this); } catch (IllegalAccessException e) { e.printStackTrace(); continue; } section.put(key, convertFrom(value)); } Ini.save(getConfigFileName(), sections); }