List of usage examples for com.google.common.collect Multimap removeAll
Collection<V> removeAll(@Nullable Object key);
From source file:org.tomahawk.libtomahawk.infosystem.hatchet.HatchetInfoPlugin.java
/** * Build a query URL for the given parameters, with which we can request the result JSON from * the Hatchet API/*from w w w. j av a 2 s. c om*/ * * @return the built query url */ private static String buildQuery(int type, Multimap<String, String> paramsIn) throws UnsupportedEncodingException { Multimap<String, String> params = null; if (paramsIn != null) { params = LinkedListMultimap.create(paramsIn); } String queryString = null; java.util.Collection<String> paramStrings; Iterator<String> iterator; switch (type) { case InfoRequestData.INFOREQUESTDATA_TYPE_USERS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYLISTS: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/" + iterator.next() + "/" + HATCHET_PLAYLISTS; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_USERS_LOVEDITEMS: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/" + iterator.next() + "/" + HATCHET_LOVEDITEMS; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_USERS_SOCIALACTIONS: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/" + iterator.next() + "/" + HATCHET_SOCIALACTIONS; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_USERS_FRIENDSFEED: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/" + iterator.next() + "/" + HATCHET_FRIENDSFEED; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYBACKLOG: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_USERS + "/" + iterator.next() + "/" + HATCHET_PLAYBACKLOG; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS_ENTRIES: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_PLAYLISTS + "/" + iterator.next() + "/" + HATCHET_PLAYLISTS_ENTRIES; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_ARTISTS + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_ALBUMS: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_ARTISTS + "/" + iterator.next() + "/" + HATCHET_ALBUMS + "/"; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_TOPHITS: paramStrings = params.get(HATCHET_PARAM_ID); iterator = paramStrings.iterator(); queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_ARTISTS + "/" + iterator.next() + "/" + HATCHET_ARTISTS_TOPHITS + "/"; params.removeAll(HATCHET_PARAM_ID); break; case InfoRequestData.INFOREQUESTDATA_TYPE_TRACKS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_TRACKS + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_ALBUMS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_ALBUMS + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_SEARCHES: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_SEARCHES + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_PLAYBACKLOGENTRIES: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_PLAYBACKLOGENTRIES + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_PLAYBACKLOGENTRIES_NOWPLAYING: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_PLAYBACKLOGENTRIES + "/" + HATCHET_PLAYBACKLOGENTRIES_NOWPLAYING + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_SOCIALACTIONS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_SOCIALACTIONS + "/"; break; case InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS: queryString = HATCHET_BASE_URL + "/" + HATCHET_VERSION + "/" + HATCHET_RELATIONSHIPS + "/"; break; } // append every parameter we didn't use if (params != null && params.size() > 0) { queryString += "?" + TomahawkUtils.paramsListToString(params); } return queryString; }
From source file:org.eclipse.xtext.serializer.sequencer.ContextFinder.java
protected Iterable<ISerializationContext> findContextsByContainer(EObject sem, Iterable<ISerializationContext> contextCandidates) { if (sem.eResource() != null && sem.eResource().getContents().contains(sem)) return Collections.singleton(getRootContext(sem)); EReference ref = sem.eContainmentFeature(); if (ref == null || (contextCandidates != null && Iterables.size(contextCandidates) < 2)) return contextCandidates; Multimap<IConstraint, ISerializationContext> containerConstraints = getConstraints(sem.eContainer()); int refID = sem.eContainer().eClass().getFeatureID(ref); Set<ISerializationContext> childContexts = Sets.newLinkedHashSet(); for (Entry<IConstraint, Collection<ISerializationContext>> e : Lists .newArrayList(containerConstraints.asMap().entrySet())) { IConstraint constraint = e.getKey(); Collection<ISerializationContext> contexts = e.getValue(); if (constraint.getFeatures()[refID] == null) containerConstraints.removeAll(constraint); else {//from www. ja v a2 s. c o m childContexts.addAll(createContextsForFeatures(contexts, constraint.getFeatures()[refID], sem)); } } Set<ISerializationContext> result; if (contextCandidates != null) { result = Sets.newLinkedHashSet(contextCandidates); result.retainAll(childContexts); } else result = childContexts; if (result.size() < 2) return result; Iterable<ISerializationContext> filteredContexts = findContextsByContainer(sem.eContainer(), containerConstraints.values()); childContexts = Sets.newLinkedHashSet(); for (Entry<IConstraint, Collection<ISerializationContext>> e : Lists .newArrayList(containerConstraints.asMap().entrySet())) if (intersect(filteredContexts, e.getValue())) childContexts.addAll(createContextsForFeatures(e.getValue(), e.getKey().getFeatures()[refID], sem)); result.retainAll(childContexts); return result; }
From source file:org.waveprotocol.wave.examples.fedone.waveserver.CertificateManagerImpl.java
/** * Dequeue all signer info requests for a given signer id and a specific domain. * * @param signerId to dequeue requests for * @param error if there was an error, null for success * @param domain to dequeue the signer requests for *///from w w w . j a v a 2 s . c o m private synchronized void dequeueSignerInfoRequestForDomain(ByteString signerId, FederationError error, String domain) { Multimap<String, SignerInfoPrefetchResultListener> domainListeners = signerInfoRequests.get(signerId); if (domainListeners == null) { LOG.info("There are no domain listeners for signer " + signerId + " domain " + domain); return; } else { LOG.info("Dequeuing " + domainListeners.size() + " listeners for domain " + domain); } for (SignerInfoPrefetchResultListener listener : domainListeners.get(domain)) { if (error == null) { listener.onSuccess(retrieveSignerInfo(signerId)); } else { listener.onFailure(error); } } domainListeners.removeAll(domain); if (domainListeners.isEmpty()) { // No listeners for any domains, delete the signer id for the overall map signerInfoRequests.remove(signerId); } }
From source file:uk.ac.ebi.mnb.dialog.tools.RemoveWorstStructures.java
/** * @inheritDoc//w w w . j a v a2s . co m */ @Override public void actionPerformed(ActionEvent e) { Collection<Metabolite> metabolites = getSelection().get(Metabolite.class); CompoundEdit edit = new CompoundEdit(); for (Metabolite m : metabolites) { if (m.hasAnnotation(MolecularFormula.class) && m.hasAnnotation(Charge.class)) { Multimap<Category, ChemicalStructure> map = HashMultimap.create(); Charge charge = m.getAnnotations(Charge.class).iterator().next(); Collection<MolecularFormula> formulas = m.getAnnotations(MolecularFormula.class); Set<ChemicalStructure> structures = m.getAnnotationsExtending(ChemicalStructure.class); Category best = Category.UNKNOWN; for (ChemicalStructure structure : structures) { Category validity = StructuralValidity.getValidity(formulas, structure, charge).getCategory(); map.put(validity, structure); if (validity.ordinal() > best.ordinal()) { best = validity; } } if (best == Category.CORRECT) { map.removeAll(Category.CORRECT); Collection<Annotation> worse = new ArrayList<Annotation>(map.values()); edit.addEdit(new RemoveAnnotationEdit(m, worse)); for (Annotation annotation : worse) m.removeAnnotation(annotation); } else if (best == Category.WARNING) { map.removeAll(Category.WARNING); Collection<Annotation> worse = new ArrayList<Annotation>(map.values()); edit.addEdit(new RemoveAnnotationEdit(m, worse)); for (Annotation annotation : worse) m.removeAnnotation(annotation); } } } edit.end(); getController().getUndoManager().addEdit(edit); update(getSelection()); }
From source file:com.google.javascript.jscomp.J2clClinitPrunerPass.java
private List<Node> cleanEmptyClinitReferences(Multimap<String, Node> clinitReferences) { final List<Node> newChangedScopes = new ArrayList<>(); // resolveReplacement step above should not require any particular iteration order of the // emptiedClinitMethods but we are using LinkedHashMap to be extra safe. for (Entry<String, Node> clinitReplacementEntry : emptiedClinitMethods.entrySet()) { String clinitName = clinitReplacementEntry.getKey(); Node replacement = clinitReplacementEntry.getValue(); Collection<Node> references = clinitReferences.removeAll(clinitName); for (Node reference : references) { Node changedScope = NodeUtil.getEnclosingChangeScopeRoot(reference.getParent()); if (replacement == null) { NodeUtil.deleteFunctionCall(reference, compiler); } else { replacement = replacement.cloneTree(); reference.replaceWith(replacement); compiler.reportChangeToChangeScope(changedScope); clinitReferences.put(getClinitMethodName(replacement), replacement); }/*from ww w . j a v a2 s .co m*/ newChangedScopes.add(changedScope); } } return newChangedScopes; }
From source file:com.github.rinde.rinsim.ui.SimulationViewer.java
void panelsLayout(Multimap<Integer, PanelRenderer> panels) { if (panels.isEmpty()) { createContent(this); } else {/* w w w . ja va2 s. c o m*/ final SashForm vertical = new SashForm(this, SWT.VERTICAL | SWT.SMOOTH); vertical.setLayout(new FillLayout()); final int topHeight = configurePanels(vertical, panels.removeAll(SWT.TOP)); final SashForm horizontal = new SashForm(vertical, SWT.HORIZONTAL | SWT.SMOOTH); horizontal.setLayout(new FillLayout()); final int leftWidth = configurePanels(horizontal, panels.removeAll(SWT.LEFT)); // create canvas createContent(horizontal); final int rightWidth = configurePanels(horizontal, panels.removeAll(SWT.RIGHT)); final int bottomHeight = configurePanels(vertical, panels.removeAll(SWT.BOTTOM)); final int canvasHeight = size.y - topHeight - bottomHeight; if (topHeight > 0 && bottomHeight > 0) { vertical.setWeights(varargs(topHeight, canvasHeight, bottomHeight)); } else if (topHeight > 0) { vertical.setWeights(varargs(topHeight, canvasHeight)); } else if (bottomHeight > 0) { vertical.setWeights(varargs(canvasHeight, bottomHeight)); } final int canvasWidth = size.x - leftWidth - rightWidth; if (leftWidth > 0 && rightWidth > 0) { horizontal.setWeights(varargs(leftWidth, canvasWidth, rightWidth)); } else if (leftWidth > 0) { horizontal.setWeights(varargs(leftWidth, canvasWidth)); } else if (rightWidth > 0) { horizontal.setWeights(varargs(canvasWidth, rightWidth)); } checkState(panels.isEmpty(), "Invalid preferred position set for panels: %s", panels.values()); } }
From source file:org.jclouds.rest.internal.RestAnnotationProcessor.java
private void addForm(Multimap<String, Object> formParams, FormParams form, Multimap<String, ?> tokenValues) { for (int i = 0; i < form.keys().length; i++) { if (form.values()[i].equals(FormParams.NULL)) { formParams.removeAll(form.keys()[i]); formParams.put(form.keys()[i], null); } else {// ww w . j a v a 2s . c o m formParams.put(form.keys()[i], replaceTokens(form.values()[i], tokenValues)); } } }
From source file:org.jclouds.rest.internal.RestAnnotationProcessor.java
private void addQuery(Multimap<String, Object> queryParams, QueryParams query, Multimap<String, ?> tokenValues) { for (int i = 0; i < query.keys().length; i++) { if (query.values()[i].equals(QueryParams.NULL)) { queryParams.removeAll(query.keys()[i]); queryParams.put(query.keys()[i], null); } else {/*from w ww . j av a2s . co m*/ queryParams.put(query.keys()[i], replaceTokens(query.values()[i], tokenValues)); } } }
From source file:com.google.eclipse.protobuf.scoping.ProtobufImportScope.java
@Override protected Iterable<IEObjectDescription> getAliasedElements(Iterable<IEObjectDescription> candidates) { Multimap<QualifiedName, IEObjectDescription> keyToDescription = LinkedHashMultimap.create(); Multimap<QualifiedName, ImportNormalizer> keyToNormalizer = HashMultimap.create(); for (IEObjectDescription imported : candidates) { QualifiedName fullyQualifiedName = imported.getName(); for (ImportNormalizer normalizer : normalizers) { QualifiedName alias = normalizer.deresolve(fullyQualifiedName); if (alias != null) { QualifiedName key = alias; if (isIgnoreCase()) { key = key.toLowerCase(); }//from ww w . j a v a 2s.c o m keyToDescription.put(key, new AliasedEObjectDescription(alias, imported)); keyToNormalizer.put(key, normalizer); } } } for (QualifiedName name : keyToNormalizer.keySet()) { if (keyToNormalizer.get(name).size() > 1) keyToDescription.removeAll(name); } return keyToDescription.values(); }
From source file:com.pidoco.juri.JURI.java
public JURI removeQueryParameter(String name) { startChange();/* w w w . ja v a 2 s . c om*/ Multimap<String, String> params = getQueryParametersMultimap(); params.removeAll(name); changed(); return this; }